Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'BudgetDataSet1.Bank' table. You can move, or remove it, as needed.
Dim sb As String = "SELECT BankID, BankName"
sb &= vbCrLf & "FROM Bank"
sb &= vbCrLf & "ORDER BY BankName"
Dim stConn As String = "Data Source=.\SQLExpress;Initial Catalog=Test;User ID=sa;Password=xxxxxxx"
Dim sqlCn As New SqlClient.SqlConnection(stConn)
Try
sqlCn.Open()
Dim sqlCmd As New SqlClient.SqlCommand(sb, sqlCn)
Dim da As New SqlClient.SqlDataAdapter(sqlCmd)
da.Fill(Me.ds, "Bank")
' Combo 1
Me.bsBank.DataSource = Me.ds
Me.bsBank.DataMember = "Bank"
Me.z_BankName.DataSource = Me.bsBank
Me.z_BankName.DisplayMember = "BankName"
' Combo 2
Me.bsBank2.DataSource = Me.ds
Me.bsBank2.DataMember = "Bank"
Me.z_BankName2.DataSource = Me.bsBank2
Me.z_BankName2.DisplayMember = "BankName"
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
sqlCn.Close() : sqlCn.Dispose()
End Try
End Sub
End Class