-
HELP! Problems with INSERT
I'm using IIS, Access 2000 for database, and ASP/ADO.
I need to add a record to a table. I've checked my code and made a lot of changes and it still doesn't work. IE gives me this message: "Syntax error in INSERT INTO statement".
Would someone please take a look at my code and tell me how to fix it?
Thanx!!!!!
heres my code:
<%
User=Request.Form("txtUsername")
Pass=Request.Form("txtPassword")
set conntemp=Server.CreateObject("ADODB.Connection")
conntemp.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
sql="INSERT INTO LoginTable (username,password)"
sql=sql & " VALUES ('" & User
sql=sql & "','" & Pass
sql=sql & "')"
conntemp.execute(sql)
set conntemp = Nothing
%>
-
try this:
sql="INSERT INTO LoginTable (username, password)" _
& " VALUES (" & User & ", " & Pass & ")"
-
It gives me the same thing... syntax error in INSERT INTO statement.
It references to the code line where the conntemp.execute(sql) appears.
I really don't understand why... 
Last edited by nectar; 08-13-2004 at 09:10 PM.
-
Is the table named [LoginTable]? Is there a space in it?
-
I think the connection string is giving you the problem try this out.
This worked out for me.
<%
User=Request("txtUsername")
Pass=Request("txtPassword")
set conntemp=Server.CreateObject("ADODB.Connection")
ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Persist Security Info=False;DBQ=" & Server.MapPath(".") & "/users.mdb"
conntemp.Open ConnectionString
strsql=" INSERT INTO LoginTable (username,password)"
strsql=strsql & " VALUES ('" & User
strsql=strsql & "', '" & Pass
strsql=strsql & "') "
conntemp.Execute strsql
set conntemp = Nothing
%>
Hope it solves your issue.
-Nagasree
-
I tried it but another error appeared, this time on line 15 (conntemp.Execute strsql).
IE gives me
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
Laurel... my table's name is LoginTable, no spaces in between.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks