那位高手帮我看一下,vb的登陆界面问题 必有重谢!!

来源:百度知道 编辑:UC知道 时间:2024/05/28 01:57:19
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=syrh;Data Source=127.0.0.1"
conn.Open
from1.Show '登录界面
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim strSQl As String
strSQl = "select * from Users where users_name='" & Trim$(Text1.Text) & "' and password='" & Trim$(Text2.Text) & "' "

Dim str As New A

password=sa;Initial Catalog=syrh;Data Source=127.0.0.1"这个有问题的,它是连接本地ip得。肯定无法连接了啊

conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=syrh;Data Source=127.0.0.1"
这段代码的问题,没有连接到数据库,你要修改一下.看看ip对吗?还有SQL的用户密码.

cnn = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=用户名;Password=用户密码;Initial Catalog=数据库名Data Source=主机名或ip"