choobakka Posted February 6, 2006 Share Posted February 6, 2006 i have followed the ADO tutorials on this site and im upto the last part. i would like to insert the changes made into the database.<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") & "'," WHERE tblCustomer.[CustomerID]=" & CustomerID "' conn.Execute sql, Recordsaffected' if err <> 0 then' Response.Write("You do not have permission to update this database!")' else ' Response.Write("Record number " & no & " was updated.")' end if Response.Write("Submitting records has been disabled from this demo")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 has been disabled from this demo")end ifconn.close%></body></html>it is the last part (in red) which i am having difficulty with. everthing else works fine. i simply want the save and delete buttons to work. thanks in advance Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 the line that actually executes the delete staement is commented out.Is the exact code that you cannot get to work????If so un comment the delete staement and let us know if it works or what errors you get. Link to comment Share on other sites More sharing options...
choobakka Posted February 6, 2006 Author Share Posted February 6, 2006 everything upto the red code works. when i click on the save and delete buttons, the code is executed but i get a messaage saying that updating and deleteing is not allowed (ie i dont have the permission). all i need is to be able to get the Save and Delete buttons to execute successfully (ie Save or Delete from the database. at the moment, this is not the case. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 please post the page that contains the 2 buttons then...I need to see the code that sends the querystring 'action' Link to comment Share on other sites More sharing options...
choobakka Posted February 6, 2006 Author Share Posted February 6, 2006 The code with the 2 buttons is below:<%CustomerID=Request.Form("CustomerID")if CustomerID="" then response.endset conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0"conn.open(server.mappath("disso1.mdb"))set rs = Server.CreateObject("ADODB.Recordset")rs.Open "Select * from tblCustomer where tblCustomer.[CustomerID]=" & CustomerID , conn%><html><head><title>Edit DataBase Table</title></head><body><h2>Edit Database Table</h2><form method="post" action="demo_db_submit.asp" target="_blank"><input name="CustomerID" type="hidden" value=<%=CustomerID%>><table bgcolor="#b0c4de"><%for each x in rs.Fields if x.name <> "no" and x.name <> "dateadded" then%> <tr> <td><%=x.name%> </td> <td><input name="<%=x.name%>" value="<%=x.value%>" size="20"></td> <%end ifnextrs.closeconn.close%></tr></table><br /><input type="submit" name="action" value="Save"><input type="submit" name="action" value="Delete"></form></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 On the 2nd page place this piece of code as the first line in your ASP code.. Response.Write(Request.Form("action")) This will show what values are really being sent as action. Click both buttons and post the values you get for each Link to comment Share on other sites More sharing options...
choobakka Posted February 6, 2006 Author Share Posted February 6, 2006 I get the same messages as before.for the save button:Submit to DatabaseSubmitting records has been disabled from this demo for the delete button:Submit to DatabaseDeleting records has been disabled from this demo a new window opens which means that the buttons are executing to some extent. it is simply not INSERTING or DELETING from the database. maybe i am missing some code! Link to comment Share on other sites More sharing options...
choobakka Posted February 6, 2006 Author Share Posted February 6, 2006 any ideas? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 I can't see any reason why it should work...maybe someone else can spot the problem..sorry Link to comment Share on other sites More sharing options...
netcracker Posted February 6, 2006 Share Posted February 6, 2006 Do the records get deleted or not ?!?!if not: 1. try naming the buttons save/delete... 2. see if user "everyone" has the read/write capability for the database ! 3. check readonly attributes for that database or the containing folder...see what happens... Link to comment Share on other sites More sharing options...
choobakka Posted February 6, 2006 Author Share Posted February 6, 2006 If you yourself go to the ADO demp page: http://www.w3schools.com/ado/ado_demo.aspclick on the link which says "List, edit, update, and delete database records"you are presented with the first ASP page.then click on any of the buttons within the table. this takes you to the second ASP page.on this page you are able to edit the current database data.THIS IS THE STAGE THAT I AM AT.if you then click on SAVE or DELETE you get a page that either says:Submit to DatabaseSubmitting records has been disabled from this demo orSubmit to DatabaseDeleting records has been disabled from this demo.this is exactly what i get when i click on the buttons.below is the code i have for the ASP page once either of the buttons is pressed:<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") & "'," WHERE tblCustomer.[CustomerID]=" & CustomerID "' conn.Execute sql, Recordsaffected' if err <> 0 then' Response.Write("You do not have permission to update this database!")' else ' Response.Write("Record number " & no & " was updated.")' end if Response.Write("Submitting records has been disabled from this demo")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 has been disabled from this demo")end ifconn.close%></body></html>this ASP page however only results in either of the two messages mentioned above and there is no interaction with the database once either button is pressed. Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 dude, are u doing this on localhost or a server of your own? or are you doing it from their server?! maybe the database is readonly or there is a write privelledge needed.the code should work as it is!do this on your pc. insltall IIS and run it for your self Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 i am using my localhost with IIS. Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 is the drive with the database ntfs or fat32 ?!if it is ntfs, right click the folder containing the database and select "security" - "add..." - "advanced" - "find now" an then look for the group called "everyone" ! then click OK to the previous windows to confirm the addmition until you get back to the properties window.click "everyone" (the group that you have just added) and then sellect "full control".try it like this, see what happends.oh, if the partition table is fat32, I donnow how to do it Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 it is NTFS. when i rightclick the folder the only things that says security is 'sharing and security'. if i select this i get a window with 4 tabs - general, sharing, web sharing, and customize. is this correct and if so what do i do next? Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 in any windows explorer window in the TOOLS menu click "Folder Options" -> VIEW -> and the last one on the list should be "Use simple file sharing..." = Uncheck that!then try again as i've instructed you in my previous postkeep in touch Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 i did that. the same thing happens: just telling me that submitting data has been disabled from the demo have i done something wrong in the coding? Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 have a look: 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") & "',"  WHERE tblCustomer.[CustomerID]=" & CustomerID "Response.Write("Submitting records has been disabled from this demo")end ifIT IS NORMAL TO SAY THAT !! but it does not mean it !!! oh, man...give it a shot like this: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") & "',"   WHERE tblCustomer.[CustomerID]=" & CustomerID "  Response.Write(" yuppy, we did it !!")else  Response.Write("Submitting records has been disabled from this demo")end if Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 im aware of that lol. but even after a submit button is pressed, nothing changes in the database. that is my main gripe. im not worried about the message afterwards. its the inputting into the database which aint working! Link to comment Share on other sites More sharing options...
netcracker Posted February 7, 2006 Share Posted February 7, 2006 what does this give you ? Â Response.Write(sql) Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 i replaced the first response.write with the response.write(sql). same result could my SQL statements be wrong? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 7, 2006 Share Posted February 7, 2006 i replaced the first response.write with the response.write(sql). same result  could my SQL statements be wrong?<{POST_SNAPBACK}> They wanted you to post the results of the above staement that way they could see exactly what sql statement is being executed and to see if infact the sql is wrong Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 how do you mean results. the only result i get is the message saying that i cannot submit records etc and there is also no change in the database. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 7, 2006 Share Posted February 7, 2006 do this and then copy and paste whatever is displayed in your browser to a post. 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") & "'," Â WHERE tblCustomer.[CustomerID]=" & CustomerID " Response.Write(sql) Response.Write(" yuppy, we did it !!")else Response.Write("Submitting records has been disabled from this demo")end if Link to comment Share on other sites More sharing options...
choobakka Posted February 7, 2006 Author Share Posted February 7, 2006 same thing again :)same thing about not being able to submit date and no change in database Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now