34,576
社区成员
发帖
与我相关
我的任务
分享
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.ConnectionString = "provider=Microsoft..OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WindowsApplication5\WindowsApplication5\database1.sdf" '这里是不是还需要用户名和密码呢??
'与数据库的连接不用打开就可以使用吗?VB 应该不会这么特殊吧...
Dim strSQL As String
strSQL = " SELECT * FROM 用户表 WHERE 用户名= '" & TextBox1.Text & "' AND 密码= '" & TextBox2.Text & "'"
If strSQL = 0 Then '这里少了个命令函数!
MsgBox("用户名不正确")
Else
Form2.Show()
MsgBox("登录成功")
End If
End Sub
End Class