title: Button Click for asp to Delete Row in SQL server - classic asp and vbscript
body: <p>I've created a webpage in asp to display a table from SQL database. I then added Buttons to each table row to update and delete each row code - </p>
  
  <pre><code>    do while not objRS.EOF
  
      %&gt;
  
      &lt;tr&gt; 
          &lt;td&gt;&lt;%= objRS("Id") %&gt; &lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Name") %&gt; &lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Address") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Suburb") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Postcode") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Age") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= objRS("Email") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;Center&gt;&lt;input type="submit" value="Update"&gt;&lt;/Center&gt;&lt;/td&gt;
          &lt;td&gt;&lt;center&gt;&lt;input type="Submit" onclick="delete(&lt;%= objRS("Id") %&gt;)" value="Delete"&gt;&lt;/center&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;%
          objRS.MoveNext
          loop    
          objCon.close
      %&gt;
  </code></pre>
  
  <p>also i the code to delete - </p>
  
  <pre><code>    Function delete(index)
  
          Dim objCon, objRS, dSQL      
          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"
  
          dSQL = "DELETE FROM Customer WHERE Id=" &amp; index
  
          objCon.execute(dSQL)            
          objCon.close     
      End Function
  </code></pre>
  
  <p>I've looked everywhere but cant seem to find how to identify each different button and delete the corresponding row from the database</p>