PDA

View Full Version : ASP -> ADO -> SQL insert record problem


qaidskey
February 14th, 2003, 09:35 PM
i have a problem with some code. im trying to write an asp program that will add some a new record into a database table (with asp ado and sql). heres the code:

html>
<body>

<%
on error resume next
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "C:\Inetpub\wwwroot\BNB\bnbuserbase\bnb.mdb"

sql="INSERT INTO UserInfo"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("username") & "',"
sql=sql & "'" & Request.Form("pwd") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & Request.Form("fname") & "',"
sql=sql & "'" & Request.Form("lname") & "',"
sql=sql & "'" & Request.Form("telnum") & "',"
sql=sql & "'" & Request.Form("worknum") & "',"
sql=sql & "'" & Request.Form("street") & "',"
sql=sql & "'" & Request.Form("city") & "',"
sql=sql & "'" & Request.Form("zippost") & "',"
sql=sql & "'" & Request.Form("stateprov") & "',"
sql=sql & "'" & Request.Form("country") & "',"
sql=sql & "'" & Response.write(date()) & "',"
sql=sql & "'No')"

conn.Execute sql
if err <> 0 then
objerr.description
objerr.nativeerror
objerr.source
else
end if
conn.close
%>

</body>
</html>

as you can see there are some form entries that need to be added. and one that i want to be the only one to control. when i test it out. i get no error objects but it still doesn't work. if i remembore the "if err..." part it gives me an internet explorer error and tells me that line 26 or w/e (the 'conn.execute sql' part) and that it has to be an updatable query. i dun't know why this happens. any help out there?

smurfy
February 20th, 2003, 10:40 AM
Hiya qaidskey, sorry to take so long to reply.

I haven't done a lot with Access databases (use MSSQL server) but it's possible you need to open up security to the "users" group on the tables you want to update.
Open your bnb database and Tools>Security>User&Group Permissions.
Make sure the "users" group has Read, Update & Insert permissions on the tables you want to insert the records to.

Or else it could be a little simpler.

INSERT INTO? tablename (column list) VALUES (values list)

In SQLServer I don't need the INTO keyword unless using "SELECT INTO tablename" etc

Try deleting the "INTO" from your code?

qaidskey
February 21st, 2003, 12:12 AM
well actually i got it to work. a friend showed me that u need to disable some sharing thing in explorer, and then edit the security properties manually. but thanx ne ways.

ninjaijr
October 27th, 2004, 10:42 PM
hey qaid could you plz post/email me the solution i am having the same issue