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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinXP Pro and IIS problem

Status
Not open for further replies.

karmafree

Programmer
May 10, 2001
107
GB
Hey,

The below "INSERT INTO" code used to work fine with my Win98 computer running Personal Web Server. Now I've ported it to a WinXP Pro computer running IIS and get the following error:

Code:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/MySite/MyScript.asp, line 18

Here is the code:

Code:
<%
Dim sql, connection, dsn

ID = Request.Form(&quot;txtID&quot;)
Name = Request.Form(&quot;txtName&quot;)
Age = Request.Form(&quot;txtAge&quot;)

sql = &quot;&quot;
sql = sql & &quot;INSERT INTO MyTable (id, name, age)&quot;
sql = sql & &quot;VALUES ('&quot;& ID &&quot;', '&quot;& Name &&quot;', '&quot;& Age &&quot;');&quot;

Set connection = Server.CreateObject(&quot;ADODB.Connection&quot;)
dsn = &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;MyDatabase.mdb&quot;)

connection.Open dsn
connection.Execute(sql) ' This is the error line 18
connection.Close

Set connection = Nothing

response.redirect(&quot;thanks.asp&quot;)
%>

Thank you,
karmafree.
 
Is it possible that the ID you're passing in already exists in the database, and its telling you you can't insert a duplicate record so you must update it?

Jack
 
Is the ID-field a text field? If it's a number field then you should omit the single quotes in the sql:

sql = sql & &quot;INSERT INTO MyTable (id, name, age)&quot;
sql = sql & &quot;VALUES (&quot; & ID & &quot;,'&quot; & Name & &quot;', '&quot;& Age &&quot;');&quot;

Take a look at the AGE-field also in case it requires a number:

sql = sql & &quot;INSERT INTO MyTable (id, name, age)&quot;
sql = sql & &quot;VALUES (&quot; & ID & &quot;,'&quot; & Name & &quot;', &quot;& Age &&quot;)&quot;

Back to the ID-field. If it's an auto-number then Access will generate the ID automatically when you insert a new row into the table. In that case you have to set up the sql like this:

sql = sql & &quot;INSERT INTO MyTable (name, age)&quot;
sql = sql & &quot;VALUES ('&quot;& Name &&quot;', '&quot;& Age &&quot;')&quot;

Olav

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top