Public Class Form1 Private cn As New SqlClient.SqlConnection Private cm As SqlClient.SqlCommand Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load cn.ConnectionString = 接続文字列 cn.Open() cm = cn.CreateCommand() End Sub Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating Call GetData1() 'Closeなし End Sub Private Sub TextBox2_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox2.Validating Call GetData2() 'Closeあり End Sub Private Sub GetData1() Dim dr As SqlClient.SqlDataReader cm.CommandText = "SELECT * FROM [テーブル1] WHERE [フィールド1] = '" & TextBox1.Text & "'" dr = cm.ExecuteReader() If dr.Read() Then Label1.Text = dr("フィールド2") End If 'dr.Close() End Sub Private Sub GetData2() Dim dr As SqlClient.SqlDataReader cm.CommandText = "SELECT * FROM [テーブル2] WHERE [フィールド1] = '" & TextBox2.Text & "'" dr = cm.ExecuteReader() If dr.Read() Then Label1.Text = dr("フィールド2") End If dr.Close() End Sub End Class