Dim txt1 As WinForm.TextBox = e.Form.Controls("TextBox1") Dim txt2 As WinForm.TextBox = e.Form.Controls("TextBox2") Dim count As Integer Dim cmd As New SQLCommand 'cmd.C cmd.CommandText = "Select Count(*) From {表名} where 列名 = '" & txt1.Text & "'" count = cmd.ExecuteScalar()