Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't update a Access database

Status
Not open for further replies.

hdougl1

Programmer
Dec 6, 2000
54
US
Help I Can't update a Access database with the following code any sugestions thanks in advance.

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString= "DRIVER={MICROSOFT Access Driver (*.mdb)}; DBQ=C:\Inetpub\Conn.Open

Set rstProducts = Server.CreateObject("ADODB.RecordSet")
rstProducts.Open "Products", Conn, 3 ,3
rstProducts.AddNew
rstProducts("ProductName") = Request.Form("ProductName")
rstProducts("UnitPrice") = Request.Form("UnitPrice")
rstProducts("ReorderLevel") = Request.Form("ReorderLevel")
rstProducts("LeadTime") = Request.Form("LeadTime")
rstProducts.Update
Conn.Close
Set conn = nothing
rstProducts.Close
Set rstProducts = nothing
 
The connection string is not right. Here is an example:

path = server.MapPath("/fluidsman/fluidsman.mdb")
connectme = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& path &";"
Conn.Open connectme
 
Thanks a lot for the suggestion, I'm getting another error now "Cannot update. Database or object is read-only." pointing to the line rstProducts.AddNew I've recreated the Access database insuring there are no passwords or security settings in place. I’ve been trying several different DSN less connections, and that was my last failure to connect and add a new record.
 
I always use the code below, always puting the metadata type include at the top of the page. I also always asign the form values to varibles. Hope this helps!


<!-- METADATA TYPE=&quot;typelib&quot;
FILE=&quot;C:\Program Files\Common Files\System\ado\msado15.dll&quot; -->
accessdb=server.mappath(&quot;access.mdb&quot;)
strconn=&quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot;
strconn=strconn & accessdb & &quot;;&quot;
'&quot;strconn=&quot;uid = l; pwd = l&quot;

set conntemp=server.createobject(&quot;ADODB.Connection&quot;)
conntemp.open strconn
set rstemp=server.createobject(&quot;ADODB.Recordset&quot;)
rstemp.open &quot;tablename&quot;, conntemp, adForwardOnly, adLockPessimistic, adCmdTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top