Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thanks for the help

I am trying to pass a value into SQL using ADO. My problem is im not sure what variable is being used in the select table.

Here is the form.

XML
<form action="test.aspx" name="PF" onsubmit="javascript:return Valid2();" style="margin-left: auto; margin-right: auto;">
<div style="text-align: center;">
<select name="ID" size="12" style="margin-left: auto; margin-right: auto;">
<%
Dim objConn As New SqlConnection(Application("CS"))
Dim objCmd As New SqlCommand("SELECT DISTINCT V.ID, V.Vendor FROM Vendors V INNER JOIN ServiceEntries E ON E.VID = V.ID WHERE (V.Active = 1) AND (E.Site = '" & strSite & "') ORDER BY V.Vendor", objConn)
objConn.Open()
Dim objR As SQLDataReader=objCmd.ExecuteReader()
While objR.Read()
    Response.Write("<option value=""" & objR(0).ToString() & """>" & objR(1).ToString() & "</option>")
End While
objR.Close() : objCmd.Dispose() : objConn.Close() : objConn.Dispose()
%>
</select><br />
<input type="submit" value="Send Login Info" /></div>
</form>


And here is the way im attempting to pass it

VB
<%
Dim strSQL = "Insert into Vendorpasswordrecovery(Vendor, IP) Values ('" & Request.Form("selectedIndex") & "', '" & Request.ServerVariables("REMOTE_ADDR") & "')"
Dim objConn As New SqlConnection(Application("CS"))
Dim objCmd As New SqlCommand(strSQL, objConn)
response.write(strSQL)
objConn.Open()
%>


Im not sure of what I need to use to pull the selection from the form to the ado string.
Posted
Updated 2-Dec-10 9:11am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900