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

Insert Into Access Database

Status
Not open for further replies.

ronis

Programmer
Jul 14, 2000
9
US
I am trying to insert form information into an access database. I have tried using rst.AddNew, but I get the message it is unsupported by my provider.

Also, I have tried Insert Into, which gives me the following message

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/AddProcess.asp, line 71

I've looked through several websites and books and I can't figure out how to fix this. Any help would be greatly appreciated.

Thank you.

My code is below.
strSQL = "INSERT INTO Table (Field1, Field2) VALUES ('" & strField1 & "', '" & strField2 & "')"

strDBPath = Server.MapPath("AccessDatabase.MDB")

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
Set rst = conn.Execute(strSQL)
 
Since your SQL statement is not one that returns a recordset (by using the SELECT keyword), you cannot use "Set rst =" with it.

Try conn.Execute(strSQL) by itself and it should work. Also, make sure there aren't any apostrophes in the string. (The are other posts on this site that deal with that).


[sig][/sig]
 
ronis,

you have a problem with your SQL statement:
strSQL = "INSERT INTO Table (Field1, Field2) VALUES ('" & strField1 & "', '" & strField2 & "')"

try this: it should work!!!
strSQL = "INSERT INTO Table (" & Field1 & "," & "Field2" & ") VALUES ('" & strField1 & "', '" & strField2 & "')"


hope this help,

[sig]<p>Jun Nantes<br><a href=mailto:bhudz@junnantes.com>bhudz@junnantes.com</a><br><a href= Nantes Official Internet Site</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top