Display data from database into textbox that matches listbox values

Vishal Rane

New member
Joined
Jun 10, 2011
Messages
1
Location
Dombivli, India, India
Programming Experience
Beginner
Suppose der is one database name Customer which have columns like Cust_ID,Cust_Name,Cust_Mob,Cust_Address

And on Form der are one list box which contains all Cust_Id from database
and 4 textbox
so when user click on the listbox having id as 1 it should display name, mob and address of cust_id 1 in 4 textbox respectively pls help me asap........
This is what i have done so far




  1. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
  2. dbSource = "Data Source=xx-B4C521B850\SQLEXPRESS;Initial Catalog=TT;Integrated Security=True"
  3. con.ConnectionString = dbSource
  4. con.Open()
  5. sql = "Select Cust_Fn from Cust where Cust_Id='" & ListBox1.Text & "' "
  6. da = New SqlClient.SqlDataAdapter(sql, con)
  7. da.Fill(ds, "Cust")
  8. con.Close()
  9. TextBox1.Text = ds.Tables("Cust").Rows(0).Item(0)
  10. End Sub'



Thanks in advance....
 
Back
Top