Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating sql server through classic asp and vbscript
    primarykey
    data
    text
    <p>Im trying to update details of a single customer and I'm having problems updating with the new user input. I can see the changes being passed but its not updating the sql. Here is the code - </p> <pre><code> 'Update' updateC = request.QueryString("action") if updateC = "update" then Id = request.QueryString("Id") Name = request.QueryString("Name") Address = request.QueryString("Address") Suburb = request.QueryString("Suburb") Postcode = request.QueryString("Postcode") Age = request.QueryString("Age") Email = request.QueryString("Email") end if %&gt; &lt;form method="get" action="CreateCustomer.asp"&gt; Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="text" value="&lt;%=Name %&gt;" name="Name"&gt;&lt;br/&gt; Address:&amp;nbsp; &lt;input type="text" value="&lt;%=Address %&gt;" name="Address"&gt;&lt;br/&gt; Suburb:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="Suburb" value="&lt;%=Suburb %&gt;" name="Suburb"&gt;&lt;br/&gt; Postcode: &lt;input type="text" value="&lt;%=Postcode %&gt;" name="Postcode"&gt;&lt;br/&gt; Age:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="text" value="&lt;%=Age %&gt;" name="Age"&gt;&lt;br/&gt; Email:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="text" value="&lt;%=Email %&gt;" name="Email"&gt;&lt;br/&gt;&lt;br/&gt; &lt;% if updateC = "update" then%&gt; &lt;input type="hidden" value="update" name="updateButton"&gt; &lt;input type="submit" value="Update Customer"&gt; &lt;% else %&gt; &lt;input type="hidden" value="insert" name="insert"&gt; &lt;input type="submit" value="New Customer"&gt; &lt;% end if %&gt; &lt;/form&gt; &lt;% 'Assign Variables' insertCheck = request.QueryString("insert") updCheck = request.QueryString("updateButton") if insertCheck = "insert" or updCheck = "update" then ID = request.QueryString("Id") Name = request.QueryString("Name") Address = request.QueryString("Address") Suburb = request.QueryString("Suburb") Postcode = request.QueryString("Postcode") Age = request.QueryString("Age") Email = request.QueryString("Email") end if 'update customer' updButton = request.QueryString("updateButton") if updButton = "update" and name&lt;&gt;"" then updateCustomer() end if 'Update customer sub procedure' sub updateCustomer() Dim uSQL, objCon Set objCon = CreateObject("ADODB.Connection") objCon.Open "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxx;Initial Catalog=Customer;Data Source=PC" uSQL = "UPDATE Customer SET Name = " &amp; "'" &amp; Name &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) uSQL = "UPDATE Customer SET Address = " &amp; "'" &amp; Address &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) uSQL = "UPDATE Customer SET Suburb = " &amp; "'" &amp; Suburb &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) uSQL = "UPDATE Customer SET Postcode = " &amp; "'" &amp; Postcode &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) uSQL = "UPDATE Customer SET Age = " &amp; "'" &amp; Age &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) uSQL = "UPDATE Customer SET Email = " &amp; "'" &amp; Email &amp; "'" &amp; " Where ID = " &amp; "'" &amp; Id &amp; "'" objCon.Execute(uSQL) objCon.Close end sub </code></pre> <p>The code above is from createcustomer.asp and the code below is from table.asp</p> <pre><code> &lt;td&gt;&lt;Center&gt;&lt;a href="CreateCustomer.asp?action=update&amp;Id=&lt;%= objRS("Id") %&gt;&amp;Name=&lt;%= objRS("Name") %&gt;&amp;Address=&lt;%= objRS("Address") %&gt;&amp;suburb=&lt;%= objRS("Suburb") %&gt;&amp;postcode=&lt;%= objRS("Postcode") %&gt;&amp;age=&lt;%= objRS("Age") %&gt;&amp;email=&lt;%= objRS("Email") %&gt;"&gt; &lt;input type="submit" value="Update"&gt;&lt;/a&gt;&lt;/Center&gt;&lt;/td&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload