Jump to content

UPDATING FORMS to MDB files don't work at all


Recommended Posts

HEllo.I have been trying to make a form that will enable a user to udate data in my access database file. I have read ALL the tutorials and tried by way of copy and paste all the examples and what not and nothing works. EXAMPLE of the one code page I am using which is directly C/P'd from the examples except the data base path was changed to the correct location.<html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "D:/Websites/Inetpub/Gregs/DBA/northwind.mdb"set rs=Server.CreateObject("ADODB.Recordset")rs.open "SELECT * FROM customers",conn%><table border="1" width="100%"><tr><%for each x in rs.Fields response.write("<th>" & ucase(x.name) & "</th>")next%></tr><% do until rs.EOF %><tr><form method="post" action="demo_update.asp"><%for each x in rs.Fields if lcase(x.name)="customerid" then%> <td> <input type="submit" name="customerID" value="<%=x.value%>"> </td> <%else%> <td><%Response.Write(x.value)%></td> <%end ifnext%></form><%rs.MoveNext%></tr><%loopconn.close%></table></body></html>This is apparently supposed to display a submit button or something and all I get is the table with all the fields in it from my database file. I have tried many other web sites and examples of updating data in a data base and i can not get it. I have edited the OBDC stuff on the server(IIS 6) to allow the path for the data base and adjusted the folder and IIS permissions(add-ons) so that all will be accepted. When i make a form that is suppoed to update it and hit a submit button everytime (no matter how i configure the asp page) i get a plain "Page cannot be displayed" 500 internal server error page that appears. This is seriously driving me crazy. CAN SOMEONE PLEASE HELP ME OUT WITH THIS? Thanks in anvance.

Link to post
Share on other sites
did you create a demo_update.asp?This page should contain your SQL UPDATE statement.Do you understand what I mean??If not read this tutorial.http://www.w3schools.com/sql/sql_update.asp

yes i read the tutorial. Where do you think i got this code from? I did make the new form so this one can post to it but that is not the problem. The problem is with this code above. The above code is supposed to display buttons on the page so that I can press them to update a record and no buttons are displayed when i run this code. I basically want to make 2 pages...one just shows all the data in the data base in a table and I have no problem making this page. The other page i want to make is to update the data in the data base. All I need is one basic working example of how the database data is updated and I can expand from that.Possibly if you, or someone, could post some code, say of a 2 field data base, one page displays the text, the other page(s) update it, that would solve my problems.Upon further playing with the tutorials I now have gotten a "no update permissions" thing going on and I have set permissions to max everywhere. Ya know, i m starting to think that this stuff just does not work at all.
Link to post
Share on other sites

Where is the Access database??? What are the permissions of the .mdb file itself? Try setting Everyone to Full Control.The Update permission error is a common one and can be frustrating to get past...but hang in there it really does work! :)

Link to post
Share on other sites
Where is the Access database??? What are the permissions of the .mdb file itself? Try setting Everyone to Full Control.The Update permission error is a common one and can be frustrating to get past...but hang in there it really does work! :)

The database path is correct as I had to change that or the page just errored saying can't be displayed. I did change the permissions to the folder in IIS and also in windows. I set every account in there to full control, took all "read only" off the folder and files in that folder, including the database file. Now, I have the Guest account for the internet added with full control but I do not have the everybody account added. Do i need the everybody account? Also i noticed in the code for the page that is says if error<>0 then display the "no permissions" error. Does this mean that if ANY error is generated that it will display "no permissions"?
Link to post
Share on other sites

yes that s what it means.remove

  if err<>0 then    response.write("No update permissions!")  else     response.write("Record " & cid & " was updated!")  end if

from the code and tell me what error you get then. Technically you could have a small sql syntax error (or an type of error) and that code will tell you it is a permissions error.

Link to post
Share on other sites
yes that s what it means.remove
  if err<>0 then    response.write("No update permissions!")  else     response.write("Record " & cid & " was updated!")  end if

from the code and tell me what error you get then. Technically you could have a small sql syntax error (or an type of error) and that code will tell you it is a permissions error.

I have figured out a majority of my problems...I was using dreamweaver and frontpage to copy the example text into and save the asp files that way. That was causin the error. When i copied the text into notepad and saved the files as .asp's that way, the code works. The update part still did not actually update the data fields but it did go through all the motions and it's probably a small tweak to get it to change the data fields.funny I never saw this mentioned in any of the forums, but i guess i was supposed to already know only use text editors when dealing with ASP pages. If I have any problems I can't solve with the update once i try all the tweaks I will repost here. As of now, seeing as the code produces pages that say things were updated I have something to base upon and can go from there.I know this is another topic all together, but...........how do I make table font color and cell changes on the fly...example....<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("northwind.mdb"))set rs = Server.CreateObject("ADODB.recordset")sql="SELECT Time, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday FROM greg"rs.Open sql, conn%><table width="80%" border="1" align="center" bgcolor="#ccffff"><tr><%for each x in rs.Fields response.write("<th align='center' bgcolor='#OOffff'>" & x.name & "</th>")next%></tr><%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td align="center" valign="middle" ><span class="style1"> <%Response.Write(x.value)%> </div> </span> <div align="center"></div></td> <%next rs.MoveNext%> </tr><%looprs.closeconn.close%></table>I want to change the Time cell in the table to font called "Andy" with a Yellowish font color and dark blue background but leave the mon tue-etc fields a defaut color and font. I was thinking "if-then" statements but not sure how to go about that even. Any idea's using the code above?
Link to post
Share on other sites

try this

<%for each x in rs.Fieldsif x.name = "Time" then%><td align="center" valign="middle" style="background-color:the color you want;font-family:font you want"><%else%><td align="center" valign="middle" ><%end if%><span class="style1"><%Response.Write(x.value)%></div></span> <div align="center"></div></td><%next

Link to post
Share on other sites
try this
<%for each x in rs.Fieldsif x.name = "Time" then%><td align="center" valign="middle" style="background-color:the color you want;font-family:font you want"><%else%><td align="center" valign="middle" ><%end if%><span class="style1"><%Response.Write(x.value)%></div></span> <div align="center"></div></td><%next

Hey thanks a million man!! That works GREAT!now how do I change the font color and size?
Link to post
Share on other sites
style="background-color:the color you want;font-family:font you want;color: font color you want;font-size: size you want eg 12pt"

Man you sure know you stuff.Ok, how about bolding this text?Is there a way to set the internal cell border colors and size? I know I can set the outer ring color and size but not sure about the inner cells as it makes them?Also, the headers at the top I want to change the color,size, bold, etc.....I tried to use the examples you gave for the body of this form but it errors when put in the top where the headers are. Any ideas?
Link to post
Share on other sites
style="background-color:the color you want;font-family:font you want;color: font color you want;font-size: size you want eg 12pt;border: 1px solid #000000;font-weight:bold"

border: width style colorread the CSS tut on w3schools.com for more options.For the headers the eaiest thing ot do isadd id="MainTable" to the <table>then in the <head> of your page put this

<style>#MainTable th{  color: your color;  font-size: your size;  etc...}</style>

Again see the CSS tut your more attributes and values. :)

Link to post
Share on other sites
style="background-color:the color you want;font-family:font you want;color: font color you want;font-size: size you want eg 12pt;border: 1px solid #000000;font-weight:bold"

border: width style colorread the CSS tut on w3schools.com for more options.For the headers the eaiest thing ot do isadd id="MainTable" to the <table>then in the <head> of your page put this

<style>#MainTable th{  color: your color;  font-size: your size;  etc...}</style>

Again see the CSS tut your more attributes and values. :)

Better yet instead of putting all these attribute in the style="" do this
<style>#MainTable th{  color: your color;  font-size: your size;  etc...}.TimeClass{   all those attributes here...}</style>

delete the style="" from the <td> and replace it with class="TimeClass"that is cleaner and easier to maintain.

Link to post
Share on other sites
Better yet instead of putting all these attribute in the style="" do this
<style>#MainTable th{  color: your color;  font-size: your size;  etc...}.TimeClass{   all those attributes here...}</style>

delete the style="" from the <td> and replace it with class="TimeClass"that is cleaner and easier to maintain.

ABSOLUTELY SUPERB!! LOOKS GREAT! You really got a sctrong handle on this. This forum should help alot of people.Ok, next question...how do I lock in the cell sizes. Example is the header "Wednesday" is bigger than "Friday" and therefore making the table bigger in spots. I tried locking down the pixel width and also the percentage field of the table but this appears to have no effect. Any idea's on this?I really appreciate you helpnig me out on this. I must be a real pain in the butt. So again, I really do appreciate this.
Link to post
Share on other sites
#MainTable th{ width: 150px; color: your color; font-size: your size; etc...}

or however many pixels you want. This will cause all the column in the table to be hte same width.

Once again you have proven 100% perfection. That is exactly what I needed. I think the form is now complete. Next I am going to play with an update page. I am sure you will be hearing from me.Thanks again. I bow down to your infamous wisdom!Actually, maybe i should just ask you first before attempting this....I want to make a series of check boxes for the update info.....going from top to bottom starting at the left i am gonig to put time and have each time starting from 10:00 am to 10:00 pm in 30 min incraments as check boxes, then in the middle of the page going from top to bottom I am putting a check box for each day of the week, and then on the right I am going to have 3 check boxes- one for a preset word of "AVAILABLE", another for a preset word of "RESERVED: and one more for whatever a user wants to input of say 10 characters. All the check boxes in the colums will not allow multiple check bozes to be checked except that each gategory (Time, day, other) across the top will have 1 Check all check box that will check everything in that colum. There will be a clear all and submit button at the bottom. How would you suppose the easiest way to achieve this would be possible? This might be askin to much of ya but any thoughts are most appreciated!
Link to post
Share on other sites
Thanks,No need to bow...once you've been doing htis as long as I have you'll be just as good! :)  Good Luck

Actually, maybe i should just ask you first before attempting this....I want to make a series of check boxes for the update info.....going from top to bottom starting at the left i am gonig to put time and have each time starting from 10:00 am to 10:00 pm in 30 min incraments as check boxes, then in the middle of the page going from top to bottom I am putting a check box for each day of the week, and then on the right I am going to have 3 check boxes- one for a preset word of "AVAILABLE", another for a preset word of "RESERVED: and one more for whatever a user wants to input of say 10 characters. All the check boxes in the colums will not allow multiple check bozes to be checked except that each gategory (Time, day, other) across the top will have 1 Check all check box that will check everything in that colum. There will be a clear all and submit button at the bottom. How would you suppose the easiest way to achieve this would be possible? This might be askin to much of ya but any thoughts are most appreciated!
Link to post
Share on other sites

This a situation I have. You can use tis code with some modification. It should do the trick, at least from what I understand you are trying to do.JavaScript

//---------------------------------------------------------------------------	//Check All Check Boxes	//---------------------------------------------------------------------------	function checkAll(checkState, checkId)	{  var i, j, numberOfInputs, numberOfBoxes, isCheckBox;  var inputFields = document.getElementsByTagName('input');  numberOfInputs = inputFields.length;  var checkBoxes = new Array();  j = 0;  for(i=0;i<numberOfInputs;i++)  {  	isCheckBox = (inputFields[i].id.indexOf('Check') != -1);  	if(isCheckBox)  	{    checkBoxes[j] = inputFields[i];    checkBoxes[j].checked = checkState;    j++;  	}  }	}

HTML

<div id="DocumentsTab" class="ContentWindow"><table class="UplTable" cellpadding="0" cellspacing="0" width="100%"><colgroup span="1" align="center" /><colgroup span="1" style="padding-left:5px" /><colgroup span="1" align="right" style="padding-right:5px" /><colgroup span="3" align="left" style="padding-left:5px" /><tr><td class="UplHeading" width="25"><input type="checkbox" id="Doc" onclick="checkAll(this.checked, this.id)" /></td><td class="UplHeading"><a href="?site=cbs&sort=name">Name</a></td><td class="UplHeading" width="75"><a href="?site=cbs&sort=size">Size</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=type">Type</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=uploaded">Uploaded</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=modified">Last Modified</a></td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocBook1.xlsCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_excel.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\Book1.xls" target="_blank">Book1</a></td><td class="UplItem2">14 KB</td><td class="UplItem2">xls</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocNEC-AspireBrochure.pdfCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_pdf.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\NEC-AspireBrochure.pdf" target="_blank">NEC-AspireBrochure</a></td><td class="UplItem2">325 KB</td><td class="UplItem2">pdf</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">12/9/2004</td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocNotebk1.qpwCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_quattropro.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\Notebk1.qpw" target="_blank">Notebk1</a></td><td class="UplItem2">4 KB</td><td class="UplItem2">qpw</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr><tr><td class="UplItem2"><input type="checkbox" id="Docpower.pptCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_powerpoint.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\power.ppt" target="_blank">power</a></td><td class="UplItem2">8 KB</td><td class="UplItem2">ppt</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr></table></div>

Notice how all my checkbox id end in "Check"...this is important to the JavaScript function.

isCheckBox = (inputFields.id.indexOf('Check') != -1);
Let me know if you have anymore questions.
Link to post
Share on other sites
This a situation I have. You can use tis code with some modification. It should do the trick, at least from what I understand you are trying to do.JavaScript
//---------------------------------------------------------------------------	//Check All Check Boxes	//---------------------------------------------------------------------------	function checkAll(checkState, checkId)	{  var i, j, numberOfInputs, numberOfBoxes, isCheckBox;  var inputFields = document.getElementsByTagName('input');  numberOfInputs = inputFields.length;  var checkBoxes = new Array();  j = 0;  for(i=0;i<numberOfInputs;i++)  {  	isCheckBox = (inputFields[i].id.indexOf('Check') != -1);  	if(isCheckBox)  	{    checkBoxes[j] = inputFields[i];    checkBoxes[j].checked = checkState;    j++;  	}  }	}

HTML

<div id="DocumentsTab" class="ContentWindow"><table class="UplTable" cellpadding="0" cellspacing="0" width="100%"><colgroup span="1" align="center" /><colgroup span="1" style="padding-left:5px" /><colgroup span="1" align="right" style="padding-right:5px" /><colgroup span="3" align="left" style="padding-left:5px" /><tr><td class="UplHeading" width="25"><input type="checkbox" id="Doc" onclick="checkAll(this.checked, this.id)" /></td><td class="UplHeading"><a href="?site=cbs&sort=name">Name</a></td><td class="UplHeading" width="75"><a href="?site=cbs&sort=size">Size</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=type">Type</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=uploaded">Uploaded</a></td><td class="UplHeading" width="100"><a href="?site=cbs&sort=modified">Last Modified</a></td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocBook1.xlsCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_excel.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\Book1.xls" target="_blank">Book1</a></td><td class="UplItem2">14 KB</td><td class="UplItem2">xls</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocNEC-AspireBrochure.pdfCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_pdf.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\NEC-AspireBrochure.pdf" target="_blank">NEC-AspireBrochure</a></td><td class="UplItem2">325 KB</td><td class="UplItem2">pdf</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">12/9/2004</td></tr><tr><td class="UplItem2"><input type="checkbox" id="DocNotebk1.qpwCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_quattropro.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\Notebk1.qpw" target="_blank">Notebk1</a></td><td class="UplItem2">4 KB</td><td class="UplItem2">qpw</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr><tr><td class="UplItem2"><input type="checkbox" id="Docpower.pptCheck" /></td><td class="UplItem1"><img style="float:left" src="images/icon_powerpoint.gif" alt="" /><a href="C:\Inetpub\wwwroot\imasterengine\sites\cbs\siteadmin\documents\power.ppt" target="_blank">power</a></td><td class="UplItem2">8 KB</td><td class="UplItem2">ppt</td><td class="UplItem2">4/11/2005</td><td class="UplItem2">3/10/2005</td></tr></table></div>

Notice how all my checkbox id end in "Check"...this is important to the JavaScript function.Let me know if you have anymore questions.

Totally lost me on this one. I attempted to make a page and put this code in it but I am not really sure where to put the java at and where to put the html at? All on the same page right? From what I could see if the page it is displaying file attributes and things. I jsut need something to pose the checked results to the database. Also only 1 check box per column will be allowed to be checked and will change accordingly if mutiple check boxes are attempted. I am not exactly sure what the code is for that but I am working on it.Any idea's?
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...
×
×
  • Create New...