Private Sub TbDepot_KeyUp(sender As Object, e As KeyEventArgs) Handles TbDepot.KeyUp
con = New SqlConnection("Data Source=USER\SQLEXPRESS;Initial Catalog=Sap;Integrated Security=True")
con.Open()
Dim cmd0 As New SqlCommand("select * from dbo.Depot where Code=@code", con)
cmd0.Parameters.AddWithValue("@code", TbDepot.Text)
Dim dr As SqlDataReader
dr = cmd0.ExecuteReader()
If (dr.Read()) Then
LDepot.Text = dr.Item("Name")
dr.Close()
cmd1 = New SqlCommand("Select * from dbo.Item", con)
'cmd1.Parameters.AddWithValue("@depot", TbDepot.Text)
da1 = New SqlDataAdapter(cmd1)
dt1 = New DataTable()
da1.Fill(dt1)
GvRates.DataSource = dt1
Else
MessageBox.Show("Please type the correct entry")
TbDepot.Clear()
End If
con.Close()
End Sub
请检查以下代码。