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

Could there be something wrong with my database?

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
Hey guys,

I'm having this stupid error everytime I try to add a new record to my Access 2000 database.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/intern/AdminHistory.asp, line 23

line 23 happens to be "conn.Update" can someone tell me what I'm doing wrong and what may be a possible problem here.

<%
dim conn
Set conn = Server.CreateObject(&quot;ADODB.Recordset&quot;)
conn.ActiveConnection = MM_dbconn_STRING
conn.Source = &quot;SELECT * From History&quot;
conn.CursorType = adOpenDynaset
conn.LockType = 2
conn.Open()
conn.AddNew
conn.Fields(&quot;Date&quot;).Value = yr
conn.Fields(&quot;Description&quot;).Value = evnt
conn.Update

Set conn = nothing
%>


Thanx
 
conn.CursorType = adOpenDynaset

Should be '= adOpenDynamic'

if you have your adovbs include file -- otherwise it should say '= 2'

That would be first.

Then, I would check to make sure that the variables that you are trying to assign to the fields actually have values in them -- I suspect that they do not, which is why the INSERT INTO error is being thrown...

Then, a bit of advice -- unless there is a really good reason to use the .addNew method of the recordset as opposed to a straight SQL INSERT statement solution, I would always opt for the SQL solution -- it's more efficient since you aren't playing with two objects (connection and recordset) -- but rather just using the .execute method of your connection object.

Oh yea, and another good reason for using an INSERT is that if you get that error, you can just response.write() your INSERT statement right to the screen and if the error isn't readily apparent, you can go to your actual database and try to execute the command directly -- it will usually yield more understandable error messages -- complete with line numbers, etc...

good luck! :)
Paul Prewett
penny.gif
penny.gif
 
Thanks alot, it was the conn.CursorType = adOpenDynaset stuff that was meesing me up..... Everythign works now...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top