Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
- MyBase.Load
- Dim con As New SqlConnection
- con.ConnectionString = "data source=abc;initial
- catalog=LoginDB;integrated security=true"
- cmd.Connection = con
- con.Open()
- cmd.CommandText = "search_data"
- cmd.CommandType = CommandType.StoredProcedure
- Dim dset As New DataSet
- Dim dpt As New SqlDataAdapter
- dpt.SelectCommand = cmd
- dpt.Fill(dset, "tab")
- ComboBox1.DataSource = dset.Tables("tab")
- ComboBox1.DisplayMember = "ID"
- ComboBox1.SelectedIndex = -1
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As
- EventArgs) Handles ComboBox1.SelectedIndexChanged
- cmd.CommandText = "show_date"
- cmd.CommandType = CommandType.StoredProcedure
- p = New SqlParameter
- p.ParameterName = "@id"
- p.Value = ComboBox1.Text
- cmd.Parameters.Add(p)
- Dim dset As New DataSet
- Dim dpt As New SqlDataAdapter
- dpt.SelectCommand = cmd
- dpt.Fill(dset, "tab")
- If dset.Tables("tab").Rows.Count > 0 Then
- TextBox2.Text = dset.Tables("tab").Rows(0)("name")
- End If
- End Sub
Add Comment
Please, Sign In to add comment