SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 6th, 2000, 07:26 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Inserting data into Access

<i><b>Originally posted by : seth (seth@immune.co.uk)</b></i><br /><br />I am a complete newbie to ASP but trying to pick up the language, using Dreamweaver Ultradev I have managed to create a form that will insert fields into a database. However, I keep getting internal server errors.<br /><br />Error type = "Provider (0x80004005) Unspecified error)<br /><br />I can usually load the page once but if I do a refresh it gives errors. Also, I can only get the data to insert if I am using a browser on the server itself. If I try to use the site from anywhere else, I just get a HTTP 500 Internal Server error with no explanation. <br /><br />My code is below, any help would be greatly appreciated...<br /><br />----------------------------------------------<br /><%@LANGUAGE="VBSCRIPT"%><%<br />' *** Insert Record: construct a sql insert statement and execute it<br />MM_editAction = CStr(Request("URL"))<br />If (Request.QueryString <> "") Then<br /> MM_editAction = MM_editAction & "?" & Request.QueryString<br />End If<br />If (CStr(Request("MM_insert")) <> "") Then<br /><br /> MM_tableName = "Customers"<br /> MM_fields = "title,title,',none,'',firstname,firstname,',none,' ',surname,surname,',none,'',aga,aga,none,1,0,raybu rn,rayburn,none,1,0,coalbrookdale,coalbrookdale,no ne,1,0,masterchef,masterchef,none,1,0,agavideo,aga video,none,1,0,rayburnvideo,rayburnvideo,none,1,0, survey,survey,none,1,0,cookshopinfo,cookshopinfo,n one,1,0,newsandspecials,newsandspecials,none,1,0,a ddress1,address1,',none,'',address2,address2,',non e,'',address3,address3,',none,'',addresspc,address pc,',none,'',addresscountry,addresscountry,',none, '',telephone,telephone,',none,'',email,email,',non e,'',fax,fax,',none,'',web,web,',none,'',company,c ompany,',none,'',companyposition,companyposition,' ,none,''"<br /> MM_redirectPage = "http://server"<br /><br /> ' create the insert sql statement<br /> MM_tableValues = ""<br /> MM_dbValues = ""<br /> MM_fieldsArray = Split(MM_fields, ",")<br /> For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5<br /> FormVal = CStr(Request.Form(MM_fieldsArray(i)))<br /> Delim = MM_fieldsArray(i+2)<br /> If (Delim = "none") Then Delim = ""<br /> AltVal = MM_fieldsArray(i+3)<br /> If (AltVal = "none") Then AltVal = ""<br /> EmptyVal = MM_fieldsArray(i+4)<br /> If (EmptyVal = "none") Then EmptyVal = ""<br /> If (FormVal = "") Then<br /> FormVal = EmptyVal<br /> Else<br /> If (AltVal <> "") Then<br /> FormVal = AltVal<br /> ElseIf (Delim = "'") Then ' escape quotes<br /> FormVal = "'" & Replace(FormVal,"'","''") & "'"<br /> Else<br /> FormVal = Delim + FormVal + Delim<br /> End If<br /> End If<br /> If (i <> LBound(MM_fieldsArray)) Then<br /> MM_tableValues = MM_tableValues & ","<br /> MM_dbValues = MM_dbValues & ","<br /> End if<br /> MM_tableValues = MM_tableValues & MM_fieldsArray(i+1)<br /> MM_dbValues = MM_dbValues & FormVal<br /> Next<br /> MM_insertStr = "insert into " & MM_tableName & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"<br /><br /> ' finish the sql and execute it<br /> Set MM_insertCmd = Server.CreateObject("ADODB.Command")<br /> MM_insertCmd.ActiveConnection = "dsn=aga;"<br /> MM_insertCmd.CommandText = MM_insertStr<br /> MM_insertCmd.Execute<br /><br /> ' redirect with URL parameters<br /> If (MM_redirectPage = "") Then<br /> MM_redirectPage = CStr(Request("URL"))<br /> End If<br /> If (InStr(1, MM_redirectPage, "?", vbTextCompare) = 0 And (Request.QueryString <> "")) Then<br /> MM_redirectPage = MM_redirectPage & "?" & Request.QueryString<br /> End If<br /> Call Response.Redirect(MM_redirectPage)<br />End If<br />%> <br /><%<br />set c = Server.CreateObject("ADODB.Recordset")<br />c.ActiveConnection = "dsn=aga;"<br />c.Source = "SELECT * FROM countries"<br />c.CursorType = 0<br />c.CursorLocation = 2<br />c.LockType = 3<br />c.Open<br />c_numRows = 0<br />%> <br /><html><br /><head><br /><title>kjnkj</title><br /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br /><script language="JavaScript"><br /><!--<br />function MM_swapImgRestore() { //v3.0<br /> var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;<br />}<br /><br />function MM_preloadImages() { //v3.0<br /> var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();<br /> var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)<br /> if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}<br />}<br /><br />function MM_findObj(n, d) { //v3.0<br /> var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {<br /> d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}<br /> if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];<br /> for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;<br />}<br /><br />function MM_swapImage() { //v3.0<br /> var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)<br /> if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}<br />}<br />//--><br /></script><br /></head><br /><body bgcolor="#FFFFFF" background="file:///i%7C/hosting/web/iclientarea.co.uk/website/454/testarea/main/contact_us/media/background.jpg" onLoad="MM_preloadImages('file:///i%7C/hosting/web/iclientarea.co.uk/website/454/testarea/main/contact_us/media/home_page_on.gif')"><br /><form name="form1" method="post" action="<%=MM_editAction%>"><br /> <div id="DBStyleImage1" style="left: 0px; top: -1px"> <br /> <p><img id="Image1" name="Image1" class="Normal" src="file:///i%7C/hosting/web/iclientarea.co.uk/website/454/testarea/main/contact_us/media/request_information.jpg" width="299" height="28" border="0"> <br /> </p><br /> <div id="Layer1" style="position:absolute; width:87px; height:15px; z-index:1; left: 64px; top: 53px"><font face="Arial" size="1"><i><font color="#CC6600">Title</font></i></font></div><br /> <div id="Layer2" style="position:absolute; width:85px; height:16px; z-index:2; left: 154px; top: 52px"><font face="Arial" size="1"><i><font color="#CC6600">First <br /> Name </font></i></font></div><br /> <div id="Layer3" style="position:absolute; width:67px; height:18px; z-index:3; left: 303px; top: 49px"><font face="Arial" size="1"><i><font color="#CC6600">Surname</font></i></font></div><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> <br /> <div align="right"><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i> <br /> name:</i></font> <br /> <input type="text" name="title" size="8"><br /> <font face="Arial"></font><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i></i></font></div><br /> </td><br /> <td width="23%"> <br /> <input type="text" name="firstname"><br /> </td><br /> <td width="58%"> <br /> <input type="text" name="surname"><br /> <font color="#CC6600" size="3">*</font> </td><br /> </tr><br /> </table><br /> <div id="Layer7" style="position:absolute; width:184px; height:396px; z-index:7; left: 528px; top: 0px"> <br /> <p><a href="file://///hosting/web/iclientarea.co.uk/website/454/testarea/flash_main.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','file:///i%7C/hosting/web/iclientarea.co.uk/website/454/testarea/main/contact_us/media/home_page_on.gif',1)"><img name="Image2" border="0" src="file:///i%7C/hosting/web/iclientarea.co.uk/website/454/testarea/main/contact_us/media/home_page_off.gif" width="90" height="35"><br><br /> </a><font face="Arial" size="1"><i><font color="#CC6600"><br><br /> i would like to request:</font></i></font></p><br /> <p><font face="Arial, Helvetica, sans-serif"> <br /> <input type="checkbox" name="aga" value="checkbox"><br /> <font size="2">Aga brochure<br><br /> </font></font> <br /> <input type="checkbox" name="rayburn" value="checkbox"><br /> <font face="Arial, Helvetica, sans-serif" size="2">Rayburn brochure <br><br /> <input type="checkbox" name="coalbrookdale" value="checkbox"><br /> Coalbrookdale brochure<br><br /> <input type="checkbox" name="masterchef" value="checkbox"><br /> Masterchef brochure<br><br /> <input type="checkbox" name="agavideo" value="checkbox"><br /> Aga video<br><br /> <input type="checkbox" name="rayburnvideo" value="checkbox"><br /> Rayburn Video<br><br /> <input type="checkbox" name="survey" value="checkbox"><br /> Home survey<br><br /> <input type="checkbox" name="cookshopinfo" value="checkbox"><br /> Aga Cook Shop information<br><br /> <input type="checkbox" name="checkbox822" value="checkbox"><br /> Do you wany your details shared?<br><br /> <input type="checkbox" name="newsandspecials" value="checkbox" checked><br /> Please inform me of any news or special offers. </font></p><br /> </div><br /> <div id="Layer4" style="position:absolute; width:63px; height:13px; z-index:4; left: 70px; top: 158px"><font face="Arial" size="1"><i><font color="#CC6600">House <br /> No </font></i></font></div><br /> <br><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> <br /> <div align="right"><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i>address:</i></font> <br /> <input type="text" name="housenumber" size="8"><br /> </div><br /> </td><br /> <td width="81%"> <br /> <input type="text" name="address1" size="46"><br /> <font color="#CC6600" size="3">*</font> </td><br /> </tr><br /> </table><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> </td><br /> <td width="81%"> <br /> <input type="text" name="address2" size="46"><br /> </td><br /> </tr><br /> <tr> <br /> <td width="19%"> </td><br /> <td width="81%"> <br /> <input type="text" name="address3" size="46"><br /> </td><br /> </tr><br /> <tr> <br /> <td width="19%"> </td><br /> <td width="81%"> <br /> <input type="text" name="addresspc" size="10"><br /> <font color="#CC6600" size="3"> *</font> <br /> <select name="addresscountry"><br /> <%<br />While (NOT c.EOF)<br />%> <br /> <option value="<%=(c.Fields.Item("Country").Value)%>"><%=(c.Fields.Item("Country").Value)%></option><br /> <%<br />c.MoveNext()<br />Wend<br />%> <br /> </select><br /> </td><br /> </tr><br /> </table><br /> <div id="Layer5" style="position:absolute; width:52px; height:16px; z-index:5; left: 140px; top: 227px"><font face="Arial" size="1"><i><font color="#CC6600">Postcode</font></i></font></div><br /> <br><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> <br /> <div align="right"><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i>telephone:</i></font> <br /> </div><br /> </td><br /> <td width="81%"> <br /> <input type="text" name="telephone" size="20"><br /> <font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i>email:</i></font> <br /> <input type="text" name="email" size="15"><br /> </td><br /> </tr><br /> </table><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> <br /> <div align="right"><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i>fax:</i></font> <br /> </div><br /> </td><br /> <td width="81%"> <br /> <input type="text" name="fax" size="20"><br /> <font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i> <br /> www:</i></font> <br /> <input type="text" name="web" size="16"><br /> </td><br /> </tr><br /> </table><br /> <table width="89%" border="0"><br /> <tr> <br /> <td width="19%"> <br /> <div align="right"><font face="Arial" size="1" point-size="8" style="font-size:8 pt"><i>company:</i></font> <br /> </div><br /> </td><br /> <td width="81%"> <br /> <input type="text" name="company" size="20"><br /> <input type="text" name="companyposition" size="21"><br /> </td><br /> </tr><br /> </table><br /> <br><br /> </div><br /> <div id="Layer6" style="position:absolute; width:40px; height:15px; z-index:6; left: 246px; top: 226px"><font face="Arial" size="1"><i><font color="#CC6600">County</font></i></font></div><br /> * - please complete these compulsory fields, so the information can be posted <br /> to you. <br /> <input type="submit" name="Submit" value="Send"><br /> <input type="hidden" name="MM_insert" value="true"><br /></form><br /></body><br /></html>

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Inserting data into Access


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT