16,554
社区成员
发帖
与我相关
我的任务
分享
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As New SqlConnection("Data Source=ZYX-PC;Initial Catalog=tongrentang;Integrated Security=True")
Dim strSql As String
strSql = "select username,password from login where username='" & Me.TextBox1.Text & "' and password='" & Me.TextBox2.Text & "'"
Dim myAdapter As New SqlDataAdapter(strSql, myConnection)
Dim myDataset As New DataSet
myAdapter.Fill(myDataset, "user")
If myDataset.Tables("user").Rows.Count = 0 Then
MsgBox("用户名或密码错误!")
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox1.Focus()
Else
Dim f2 As New Form2()
Me.Hide()
f2.Show()
End If
End Sub