Jump to content

Inserting a record with asp classic


Alizhane

Recommended Posts

Hi EveryoneI need help, I always get this error "No Update Permissions" which I coded for error handling, but well I don't even know what that means, any please explain what could be the problem because every thing seem to be ok, my select code works fine. The Insert is giving me hassels. :)View the code below:<html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "C:/inetpub/wwwroot/test/test.mdb"sql="INSERT INTO users (Firstname,Lastname)"sql=sql & " VALUES "sql=sql & "('" & Request.Form("firstname") & "',"sql=sql & "'" & Request.Form("lastname") & "')"on error resume nextconn.Execute sql,recaffectedif err<>0 then Response.Write("No Update Permissions")else Response.Write("<h3>" & recaffected & " record added</h3>")end ifconn.close%></body></html>

Link to comment
Share on other sites

The code prints that message if the error code is not 0. Check what the error code is. I'm not sure if the err variable gets automatically set by something, but your code isn't setting that variable. You are testing it to see if you print the error message though.

Link to comment
Share on other sites

Thanks man your response is highly appreciated.No I'm not testing to see if I can print the error message, I want to insert a record without an error message showing up.In this case I believe the error code is 0, which means an error occured. question is what does code 0 means or what type of an error is code 0? could you please read the code and tell me where I could have went wrong when Inserting the data or executing the statement?Thank you.

The code prints that message if the error code is not 0. Check what the error code is. I'm not sure if the err variable gets automatically set by something, but your code isn't setting that variable. You are testing it to see if you print the error message though.
Link to comment
Share on other sites

Look at this part:if err<>0 thenResponse.Write("No Update Permissions")else Response.Write("<h3>" & recaffected & " record added</h3>")end ifYou print the error message if err is not 0. You should print err to figure out what it is. All we know at this point is that the variable err does not have the value 0, we don't know anything else until you print that variable and figure out what the actual value is.

Link to comment
Share on other sites

Hi Justy JustI managed to solve my problem, thanks for all the help I received from you and thanks to all the people who visited this posting. let's keep the ideas flowing, It's good to share. For your info The error printed " No update permissions " because variable err is not 0, which meant the system could not write to the database. My User account and other systems accounts did not have the permission to write to the Database file test.mdb the code is fine. the problem was with my Database file settings. Thanks a lot guys.

Look at this part:if err<>0 thenResponse.Write("No Update Permissions")else Response.Write("<h3>" & recaffected & " record added</h3>")end ifYou print the error message if err is not 0. You should print err to figure out what it is. All we know at this point is that the variable err does not have the value 0, we don't know anything else until you print that variable and figure out what the actual value is.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...