Hi
first of all am new to progarmming. Am using using combo box control in vb.net
combo box getting filled properly
Public Sub new_entry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cn As New SqlClient.SqlConnection("Data Source=KAU-4A76A124FB9;Initial Catalog=SRRY;Integrated Security=True")
cn.Open()
Dim adp As New SqlDataAdapter("select * from Bank_Details order by (bank_id)", cn)
Dim ds As New DataSet
adp.Fill(ds)
With Combo_Bank_1
.DataSource = ds.Tables(0)
.DisplayMember = "Bank_Name"
.ValueMember = "Bank_Id"
.SelectedIndex = 0
End With
cn.Close()
End Sub
But now i want on selected value of Combo_Bank_1 another combo box should get filled
i have tried this
Private Sub Combo_Bank_1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Combo_Bank_1.SelectedIndexChanged
Dim cn As New SqlClient.SqlConnection("Data Source=KAU-4A76A124FB9;Initial Catalog=SRRY;Integrated Security=True")
Dim adp1 As New SqlDataAdapter("select Bank_Name from Bank_Details where bank_id='" & Combo_Bank_1.SelectedValue & "'", cn)
Dim ds1 As New DataSet
adp1.Fill(ds1)
txt_PName.Text = ds1.Tables(0).Rows(0).Item(0)
If Combo_Bank_1.SelectedValue = 0 Then
MsgBox("select")
Else
txt_PName.Text = ds1.Tables(0).Rows(0).Item(0)
End If
cn.Close()
End Sub
am getting error
Operator '&' is not defined for string "select Bank_Name from Bank_Detai" and type 'DataRowView'.
i have tried converting it to string , also to int
am able to display the value of selectd index, selected value but not able to passed in sql query
if i entered value directly i.e
Dim adp1 As New SqlDataAdapter("select Bank_Name from Bank_Details where bank_id=1", cn)
Its working. but not able to passed the value from Combo_Bank_1
Plz help
thanks
Kaustubh