Private Sub txtCode_TextChanged(sender As Object, _
e As EventArgs) Handles txtCode.TextChanged
Dim objConn As New SqlConnection
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
Dim strConnString As String
strConnString = "Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
Dim strSQL As String
strSQL = "SELECT * FROM supplier WHERE Code = '" & Me.txtCode.Text & "' "
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
IF dt.Row.Count > 0 Then
Me.txtName.Text = dt.Rows(0)("Name").ToString()
Me.txtAddress.Text = dt.Rows(0)("Address").ToString()
End IF
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub