Jump to content

Insert into database


choobakka

Recommended Posts

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
anybody else got any ideas?

I think there some slip of mindplease check the SQL String for Update
	sql="UPDATE tblCustomer SET CustomerID="' & Request.Form("CustomerID") & "'," 	sql=sql & "Last_Name='" & Request.Form("Last_Name") & "',"	sql=sql & "First_Name='" & Request.Form("First_Name") & "',"	sql=sql & "Address1='" & Request.Form("Address1") & "',"	sql=sql & "Address2='" & Request.Form("Address2") & "',"	sql=sql & "Address3='" & Request.Form("Address3") & "',"	sql=sql & "Post_Code='" & Request.Form("Post_Code") & "',"	sql=sql & "Telephone1='" & Request.Form("Telephone1") & "',"	sql=sql & "Telephone2='" & Request.Form("Telephone2") & "' "	WHERE tblCustomer.[CustomerID]=" & CustomerID "

Just Change the last line WHERE tblCustomer.[CustomerID]=" & CustomerID "By sql=sql & " WHERE tblCustomer.[CustomerID]=" & CustomerIDThats it. i think this ll solve the problem

Link to comment
Share on other sites

still no change.since copying the code from the tutorials on this site, the code within the tutorials has changed.so i added the new code but now i dont get any messages about not being able to update/delete. i simply get a blank screen and there is no change in the database. the new code is as follows:<html><head><title>Submit DataBase</title></head><body><h2>Submit to Database</h2><%on error resume nextset conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0"conn.open(server.mappath("Disso1.mdb"))if Request.form("action")="Save" then CustomerID=Request.Form("CustomerID")sql="UPDATE tblCustomer SET CustomerID="' & Request.Form("CustomerID") & '"," sql=sql & "Last_Name='" & Request.Form("Last_Name") & "'," sql=sql & "First_Name='" & Request.Form("First_Name") & "'," sql=sql & "Address1='" & Request.Form("Address1") & "'," sql=sql & "Address2='" & Request.Form("Address2") & "'," sql=sql & "Address3='" & Request.Form("Address3") & "'," sql=sql & "Post_Code='" & Request.Form("Post_Code") & "'," sql=sql & "Telephone1='" & Request.Form("Telephone1") & "'," sql=sql & "Telephone2='" & Request.Form("Telephone2") & "' ," sql=sql & "Username='" & Request.Form("Username") & "' , " sql=sql & "Password='" & Request.Form("Password") & "' , "sql=sql & " WHERE tblCustomer.[CustomerID]=" & CustomerID' conn.Execute sql, Recordsaffected'if err <> 0 then' Response.Write("hello.")else' Response.Write("Record number " & CustomerID & " was updated.")' end if Response.Write("Submitting records not possible")end ifif Request.Form("action")="Delete" then CustomerID=Request.Form("CustomerID")' conn.Execute "DELETE FROM tblCustomer WHERE tblCustomer.[CustomerID]=" & CustomerID, Recordsaffected' if err <> 0 then' Response.Write("You do not have permission to delete a record from this database!")' else ' Response.Write("Record number " & no & " was deleted.")' end if Response.Write("Deleting records not possible")end ifconn.close%></body></html>from what i can see, the code in red has been added in the tutorials but i still get the same result. all i want to be able to do is update the records in the database. any other ideas would be greatly appreciated

Link to comment
Share on other sites

what you see above is the FULL code for that ASP page. it is supposed to update data in my database when it is called from a button press on another ASP page!however, this does not happen, NOTHING HAPPENS!!!!

Ok try this
if Request.form("action")="Save" then CustomerID=Request.Form("CustomerID")sql="UPDATE tblCustomer SET "sql=sql & "Last_Name='" & Request.Form("Last_Name") & "'," sql=sql & "First_Name='" & Request.Form("First_Name") & "'," sql=sql & "Address1='" & Request.Form("Address1") & "'," sql=sql & "Address2='" & Request.Form("Address2") & "'," sql=sql & "Address3='" & Request.Form("Address3") & "'," sql=sql & "Post_Code='" & Request.Form("Post_Code") & "'," sql=sql & "Telephone1='" & Request.Form("Telephone1") & "'," sql=sql & "Telephone2='" & Request.Form("Telephone2") & "' ," sql=sql & "Username='" & Request.Form("Username") & "' , " sql=sql & "Password='" & Request.Form("Password") & "' , "sql=sql & " WHERE tblCustomer.[CustomerID]=" & CustomerIDResponse.Write sqlResponse.End
This will show you the querry in hte browser.Copy this querry and run it from backend(i.e. Querry analyser etc)Is it updating the record??
Link to comment
Share on other sites

I have the same problems:Using the examples of W3School, I have made some pages.The DataBase has permissions fo 'everyone', 'me', 'administrators', etc.ect....I'm running on LocalHost, under XP-SP2, IIS.Page1:<html> <body> <H1>Add a new record</H1> <form method="post" action="ADO_Test7.1.asp"> <table> <tr> <td>Date:</td> <td><input name="Date"></td> </tr> </tr> <tr> <td>Time:</td> <td><input name="Time"></td> </tr> <tr> <td>User:</td> <td><input name="User"></td> </tr> <tr> <td>Job:</td> <td><input name="Job"></td> </tr> <tr> <td>Doc type:</td> <td><input name="DocType"></td> </tr> <tr> <td>Doc ID:</td> <td><input name="DocId"></td> </tr> <tr> <td>Connector:</td> <td><input name="Connector"></td> </tr> <tr> <td>Destination:</td> <td><input name="Destination"></td> </tr> </table> <br /> <br /> <input type="submit" value="Add New"> <input type="reset" value="Cancel"> </form> </body></html>Page2:<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "D:/StreamServe/UOMS/WhatEver/Development/RunTime/DataBase/UOMS.mdb" sql="INSERT INTO UOMS (ID,Date,Time,User,Job,DocType,DocId,Connector,Destination) VALUE (" sql=sql & "'" & Request.Form("Date") & "'," sql=sql & "'" & Request.Form("Time") & "'," sql=sql & "'" & Request.Form("User") & "'," sql=sql & "'" & Request.Form("Job") & "'," sql=sql & "'" & Request.Form("DocType") & "'," sql=sql & "'" & Request.Form("DocId") & "'," sql=sql & "'" & Request.Form("Connector") & "'," sql=sql & "'" & Request.Form("Destination") & "')" on error resume next conn.Execute sql,recaffected if err<>0 then Response.Write("Error: " & err & " No update permissions!") else Response.Write("<h3>" & recaffected & " record added</h3>") end if conn.close %> </body></html>Result after addin a record:Error: -2147217900 No update permissions! The funny this is.... If I try to DELETE a record, or a bunch of records, that WORKS!So, I can destroy, but not create....Please help....

Link to comment
Share on other sites

  • 2 weeks later...
PROBLEM SOLVED  :) i did some research and found out that the word 'password' is a reserved word in ADO/OLEDB. chnaged the name in the database and in the sql statement and it worked a charm.thanks for all your help guys

You could have wrote it this way [password] but changing it was probably the best choice anyways.Wow, 60+ posts and it turned out to be that....lol....I should have looked closer, shame on me for missing that :)
Link to comment
Share on other sites

  • 9 months later...

I've been following you guys. I had the same problem. already change the permission of the gtks.mdf database uncheck readonly etc. i can read from the db. here is the code. Connected OK error: -2147217900 No update permissions!INSERT INTO ct_mstr (ct-nbr,ct-fname)VALUE('3','rya')

I've been following you guys. I had the same problem. already change the permission of the gtks.mdf database uncheck readonly etc. i can read from the db. here is the code. Connected OK error: -2147217900 No update permissions!INSERT INTO ct_mstr (ct-nbr,ct-fname)VALUE('3','rya')
already figure out my problem. some of my fields doesnt allow nulls.. i change them to allow nulls. it works tnx guys.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...