Unable to update server-side DB from within HTML

Results 1 to 2 of 2

Thread: Unable to update server-side DB from within HTML

  1. #1
    J. O'Neil Guest

    Default Unable to update server-side DB from within HTML

    I am trying desparately to update a database on my server. I&#039m using VBScript and ASP. However, my code just ain&#039t gettin&#039 it.<BR>Sure could use some help from a guru. I&#039ve included my code within this message.<BR><BR>&#060;HTML&#062;<BR>&#060;HEAD&#06 2;<BR>&#060;TITLE&#062;ONEIL SYSTEMS, INC. - An Information Systems <BR> Company&#060;/TITLE&#062;<BR>&#060;/HEAD&#062;<BR><BR>&#060;BODY BACKGROUND="bg-offwhite.gif"&#062;<BR>&#060;STYLE&#062;a:hover {color:red}&#060;/STYLE&#062;<BR><BR>&#060;SCRIPT LANUAGE="VBScript"&#062;<BR>&#060;!--<BR>Sub button1_onClick()<BR> msgbox "Test"<BR>End Sub<BR>--&#062;<BR>&#060;/SCRIPT&#062;<BR><BR>&#060;P&#062;&#060;/P&#062;<BR>&#060;TABLE BORDER="0" WIDTH="100%" CELLSPACING="8"&#062;<BR> &#060;TR&#062;<BR> &#060;TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="5%"&#062;&#060;/TD&#062;<BR> &#060;TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="60%"&#062;&#060;IMG <BR> SRC="contactus_title.gif" WIDTH="262" <BR> HEIGHT="33"&#062;&#060;/TD&#062;<BR> &#060;TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="35%"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD VALIGN="MIDDLE" ALIGN="RIGHT" COLSPAN="3"&#062;<BR> &#060;HR SIZE="5"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR>&#060;/TABLE&#062;<BR><BR>&#060;P&#062;&#060;/P&#062;<BR><BR>&#060;TABLE WIDTH="100%" COLS="4"&#062;<BR> &#060;TR&#062;<BR> &#060;TD WIDTH="5%"&#062;&#060;/TD&#062;<BR> &#060;TD&#062;&#060;FONT SIZE="+1" COLOR="#ff0201" FACE="Arial"&#062; <BR> &#060;B&#062;&#060;I&#062;&#060;U&#062;Our Mailing Address&#060;/U&#062;&#060;/I&#062;&#060;/B&#062;&#060;/FONT&#062;&#060;/TD&#062;<BR> &#060;TD WIDTH="20%"&#062;&#060;/TD&#062;<BR> &#060;TD&#062;&#060;FONT SIZE="+1" COLOR="#ff0201" FACE="Arial"&#062; &#060;B&#062;&#060;I&#062; <BR> &#060;U&#062;Email Address&#060;/U&#062;&#060;/I&#062;&#060;/B&#062;&#060;/FONT&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD WIDTH="5%"&#062;&#060;/TD&#062;<BR> &#060;TD WIDTH="40%"&#062;&#060;FONT COLOR="black" FACE="Times New <BR> Roman"&#062;&#060;I&#062;&#060;B&#062;ONEIL SYSTEMS,INC.<BR>&#060;/B&#062;&#060;/I&#062;&#060;/FONT&#062; <BR> &#060;/TD&#062;<BR> &#060;TD WIDTH="20%"&#062;&#060;/TD&#062;<BR> &#060;TD&#062;&#060;A HREF="mailto:jeffo@donet.com"&#062;jeffo@donet.com &#060;/A&#062; <BR> <BR>&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD WIDTH="10%"&#062;&#060;/TD&#062;<BR> &#060;TD&#062;426 Crusader Drive<BR><BR> Dayton, Ohio 45449<BR><BR> Ph. (937) 866-0961<BR><BR> Fax (937) 866-5271&#060;/TD&#062;<BR> &#060;/TR&#062;<BR>&#060;/TABLE&#062;<BR><BR>&#060;P&#062;<BR>&#060;/P&#062;<BR>&#060;HR SIZE="5" WIDTH="95%" ALIGN="CENTER"&#062;<BR><BR><BR>&#060;FORM NAME="Input" METHOD="GET"&#062;<BR>&#060;TABLE BORDER="0" WIDTH="90%" ALIGN="CENTER"&#062;<BR> &#060;TR&#062;<BR> &#060;TD WIDTH="5%"&#062;<BR> &#060;TABLE&#062;<BR> &#060;TR&#062;<BR> &#060;TD COLSPAN="2"&#062;&#060;FONT FACE="Arial" SIZE="+1"&#062;&#060;B&#062; <BR> &#060;I&#062; How can we help you?&#060;/I&#062;&#060;/B&#062;&#060;/FONT&#062;<BR><BR> <BR>&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;Name: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> TYPE="TEXT" NAME="name" SIZE="25"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;Address: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> TYPE="TEXT" NAME="address" SIZE="30"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;City: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> TYPE="TEXT" NAME="city" SIZE="25"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;State: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> TYPE="TEXT" NAME="state" SIZE="2"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;Email: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> TYPE="TEXT" NAME="email" SIZE="30"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="TOP"&#062;Comments: &#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;TEXTAREA <BR> NAME="comment" ROWS="3" COLS="50"&#062; <BR> &#060;/TEXTAREA&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;TR&#062;<BR> &#060;TD ALIGN="RIGHT" VALIGN="MIDDLE"&#062;<BR><BR>&#060;/TD&#062;<BR> &#060;TD ALIGN="LEFT" VALIGN="MIDDLE"&#062;&#060;INPUT <BR> NAME="button1" TYPE="BUTTON" <BR> VALUE="Send"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR> &#060;/TABLE&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR>&#060;/TABLE&#062;<BR>&#060;/FORM&#062;<BR><BR>&#060;HR WIDTH="95%" SIZE="5"&#062;<BR><BR>&#060;TABLE BORDER="0" WIDTH="100%"&#062;<BR> &#060;TR&#062;<BR> &#060;TD WIDTH="20%"&#062;<BR><BR><BR>&#060;/TD&#062;<BR> &#060;TD WIDTH="65%" VALIGN="BOTTOM" ALIGN="CENTER"&#062;&#060;FONT SIZE="-1" COLOR="#8000FF"&#062;&#060;FONT SIZE="-1"&#062;<BR> &#060;A HREF="about_us.htm"&#062;&#060;FONT SIZE="-1"&#062;About Us&#060;/FONT&#062;&#060;/A&#062; &#124 <BR> &#060;A HREF="services.htm"&#062;&#060;FONT SIZE="-1"&#062;Services&#060;/FONT&#062;&#060;/A&#062; &#124<BR> &#060;A HREF="clients.htm"&#062;&#060;FONT SIZE="-1"&#062;Clients&#060;/FONT&#062;&#060;/A&#062; &#124<BR> &#060;A HREF="contact.htm"&#062;&#060;FONT SIZE="-1"&#062;Contact Us&#060;/FONT&#062;&#060;/A&#062; &#124<BR> &#060;A HREF="whatsnew.htm"&#062;&#060;FONT SIZE="-1"&#062;What&#039s New&#060;/FONT&#062;&#060;/A&#062; &#124<BR> &#060;A HREF="home.htm"&#062;&#060;FONT SIZE="-1"&#062;Home&#060;/FONT&#062;&#060;/A&#062;&#060;/FONT&#062;&#060;/FONT&#062;&#060;/TD&#062;<BR> &#060;TD WIDTH="15%"&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR>&#060;/TABLE&#062;<BR>&#060;/BODY&#062;<BR>&#060;/HTML&#062;<BR><BR><BR>**************************** *******************************<BR><BR>Here is the ASP file "add.asp".<BR><BR>&#060;!-- This piece of ASP code should allow an Access database to have a<BR> new row added to it. --&#062;<BR><BR>&#060;%<BR>Dim ADOConn<BR>Dim Daoconn<BR>dIM RS<BR>dim count<BR>dim adOpenDynamic<BR>adOpenDynamic = 3<BR><BR>Set ADOConn = CreateObject("Adodb.Connection") <BR>Set RS = CreateObject("ADODB.REcordSEt") &#039<BR>AdoConn.Open "Provider = Source=/ONEILSYSTEMS/OS.mdb"<BR><BR>RS.Open "collapsed",adoConn,adOpenDynamic<BR><BR>RS.addnew <BR> RS("name") = name<BR> RS("address") = address<BR> RS("city") = city<BR> RS("state") = state<BR> RS("email") = email<BR> RS("comment") = comment<BR>RS.update<BR><BR>Response.WRite Err.Description<BR>%&#062;<BR>

  2. #2
    Keith Fowler Guest

    Default RE: Unable to update server-side DB from within HT

    The first thing I would suggest to you is to surf on over to www.learnasp.com. Here you will find much info on the use of ASP.<BR><BR>Your form needs fixing first. Make the following changes to the corresponding lines in your form.<BR>&#060;FORM NAME="add.asp" METHOD="POST"&#062;<BR><BR>&#060;INPUT TYPE="Submit" VALUE="Submit"&#062;<BR><BR>Next you need to make some additions to your add.asp file.<BR>&#060;% Option Explicit %&#062;<BR>This makes sure you use the same variables throughout your code.<BR><BR>&#060;%<BR>&#039//Declare variables. Make sure you use the same spelling<BR>&#039//throughout the rest of your code.<BR>Dim ADOConn<BR>Dim RS<BR>Dim name, address, city, state<BR>Dim email, comment<BR>Dim adOpenDynamic<BR>adOpenDynamic = 3<BR><BR>&#039//Retreives the values from the HTML form<BR>name = Request.Form("name")<BR>address = Request.Form("address")<BR>city = Request.Form("city")<BR>state = Request.Form("state")<BR>email = Request.Form("email")<BR>comment = Request.Form("comment")<BR><BR>On Error Resume Next<BR><BR>Set ADOConn = Server.CreateObject("ADODB.Connection") <BR>Set RS = Server.CreateObject("ADODB.RecordSet") &#039<BR>&#039//You must specify the PROVIDER. That&#039s up to you!<BR>ADOConn.Open "Provider = Source=/ONEILSYSTEMS/OS.mdb"<BR><BR>RS.Open "collapsed",ADOConn,adOpenDynamic<BR><BR>RS.addnew <BR>RS("name") = name<BR>RS("address") = address<BR>RS("city") = city<BR>RS("state") = state<BR>RS("email") = email<BR>RS("comment") = comment<BR>RS.update<BR><BR>&#039//Write the error only if it exists.<BR>If Err &#062; 0 Then<BR> Response.Write Err.Description<BR>End If<BR>%&#062;<BR><BR>This may or may not completely solve your problem. Nonetheless, it will definitely get you off to a good start.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •