Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Data.mdb"
Dim myConn As OleDbConnection = New OleDbConnection(strConn)
myConn.Open()
Dim TestCommand As OleDbCommand = New OleDbCommand("SELECT Count(*) FROM 开奖结果 WHERE 期号=" & TextBox1.Text, myConn)
str = TestCommand.ExecuteScalar()
If Val(str) > 0 Then
myConn.Close()
MsgBox("数据库中已经存在" & TextBox1.Text & "期结果,请勿重复输入!")
Exit Sub
End If