If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Help!! Can't UPDATE Access DB using Ado!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-04, 22:14
cebolander cebolander is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
Unhappy Help!! Can't UPDATE Access DB using Ado!

Hi @ll!

I'm new at ADO and I'm trying to learn about it. I solved some problems already but I really don't know what to do about this one.

This is the problem. I've created a simple asp page with this code:

<!-- #INCLUDE file="functions.inc" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>
<% AddProd %>
</body>
</html>

And the function:

<% Sub AddProd()

' Get link info
dim CatID
CatID = Request.QueryString()

dim Prod_Name, Prod_weigth, Prod_Units, Prod_Unit_Pr

Prod_Name = Request.Form("prod_name")
Prod_weigth = Request.Form("prod_weigth")
Prod_Units = Request.Form("prod_units")
Prod_Unit_Pr = Request.Form("prod_unit_pr")

' Setting ADO Connection
set adoConn = server.createobject("adodb.connection")
adoConn.Mode = adModeReadWrite
adoConn.open connSrc

' Setting AddRs Recordset
set AddRs = server.createobject("adodb.recordset")
addRs.open "Products", adoConn, adOpenStatic, adLockPessimistic

addRs.AddNew
addRs("Product Name") = Prod_Name
addRs("Product Weigth") = Prod_Weigth
addRs("Product Name") = Prod_Units
addRs("Product Name") = Prod_Unit_Pr
addRs.Update

'Cleanup Recordset
addRs.close
set addRs = nothing


'Cleanup Connection
adoConn.close
set adoConn = nothing
End Sub
%>

My browser returns the following error:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][Controlador Microsoft Access de ODBC] Update not possible. Database or object read-only.
(translated from Portuguese)

I'm running windows XP SP1 and IIS 5.1 and I created a DSN to my DB.

What can I do to solve this problem?

Hope someone can help me.

Thank you @all very much,
Pedro
Reply With Quote
  #2 (permalink)  
Old 01-26-04, 22:24
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
You may change adOpenStatic to adOpenDynamic.
Reply With Quote
  #3 (permalink)  
Old 01-26-04, 22:30
cebolander cebolander is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
unfortunetly that didn't solve the problem...

But thaks anyway,
Pedro
Reply With Quote
  #4 (permalink)  
Old 01-26-04, 23:15
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Did you try to insert data into a table on Query Analyzer?
Reply With Quote
  #5 (permalink)  
Old 01-26-04, 23:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Err,... it's an Access Database, not a MS SQL database. Did you try inserting the data directly into the table via Access? It could be that the file is marked as read only.
Reply With Quote
  #6 (permalink)  
Old 01-27-04, 08:20
cebolander cebolander is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
I'me new at ASP/ADO but I'm sure that Access db is working fine...the problem happens when I try to update it's records from a ASP page using ADO...

But thanks anyway,
Pedro
Reply With Quote
  #7 (permalink)  
Old 01-27-04, 11:03
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
In your code

adoConn.open connSrc

what is "connSrc"?

The code should be

adoConn.Open "DSN=dsnName;UserID=userID;pwd=password"

Which one do you use to access your database?

SQL server authentication or Windows NT authentication?
Reply With Quote
  #8 (permalink)  
Old 01-27-04, 11:52
cebolander cebolander is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
Thank you @ll folks!

I managed to solve the problem on my own.

By the way what I've done was to change my connSrc to DSN-Less connection.

I saw somewhere that OBDC is obsolete so I changed to something like this:
connSrc = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=somesource;"
using OLEDB instead.

This bringed me some other problems that I've managed to solve using Microsoft Knowledge base and configuring permissions on XP and IIS 5.1.

Thanks again,
Pedro
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On