Help please -I am still learning Visual Web Developer in VB.Net code
Sorry to ask, there is probably an easy fix or I have this completely wrong.
I have a DropDownList2 (CustName) and a TextBox16 (for CustID)
I want the command to look at the SQL Table and fill the TextBox with the matching CustID for the CustName
when the CustName is selected in the DropDownList
When I run the page, I am getting no errors. I select the item in the DropDownList the AutoPostBack refreshes the page but the textbox remains empty.
ReachoutCust is the SQL Table
CustID And CustName are Fields within the table
Protected Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList2.SelectedIndexChanged
Dim cmd As New SqlCommand()
Dim con As New SqlConnection()
con = New SqlConnection("Data Source=[SERVER NAME];Initial Catalog=[SQL DATABASE NAME];Integrated Security=True")
con.Open()
cmd = New SqlCommand("SELECT CustID FROM ReachoutCust WHERE CustName = 'DropDownList2.Text'", con)
dr = cmd.ExecuteReader
While dr.Read
TextBox16.Text = dr(0).ToString()
End While
dr.Close()
End Sub