Jump to content
Sign in to follow this  
choobakka

Insert into database

Recommended Posts

any luck ASPNETGUY?

I am afriad not I am having trouble getting the pages and datbase setup. I just don't have the time to play with it. sorry.It has been so long since I setup a ASP website on my local server...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
still no change....any other ideas would be greatly appreciated

I m bit confused with the commented part and Red part in the code.Please Post Code with no Comments and Red statemets.it is interesting, because I m not facing any problem with the same code.

Share this post


Link to post
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!!!!

Share this post


Link to post
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??

Share this post


Link to post
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....

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...