What is the problem with above code?
Pgmer
Practically a Posting Shark
881 posts since Apr 2008
Reputation Points: 60
Solved Threads: 158
Skill Endorsements: 1
You can use SelectedIndexChanged
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
The default value for what? When you run the following code
Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
myCommand = New SqlCommand(" Select Name FROM [Product_Name_List] Where P_Id='" & ComboBox2.Text & "'", myConnection)
Dim dr As SqlDataReader = myCommand.ExecuteReader
ComboBox2.Items.Clear
While dr.Read()
Debug.WriteLine(dr(0))
TextBox8.Text = Val(dr(0)).ToString
End While
dr.Close()
myConnection.Close()
End Sub
what is the output in the debug window?
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Run the following code and post the output from the debug window
Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
myCommand = New SqlCommand(" Select Name FROM [Product_Name_List] Where P_Id='" & ComboBox2.Text & "'", myConnection)
Debug.WriteLine(myCommand.CommandText)
Dim dr As SqlDataReader = myCommand.ExecuteReader
ComboBox2.Items.Clear
While dr.Read()
Debug.WriteLine(dr(0))
TextBox8.Text = Val(dr(0)).ToString
End While
dr.Close()
myConnection.Close()
End Sub
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
How many times are you planning to ignore my request for you to post the output (in the debug window) from your code?
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Question Answered as of 6 Months Ago by
Reverend Jim
and
Pgmer No trouble. Glad you got it working.
Reverend Jim
Illigitimae non carborundum
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33