Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim SQL As String
Dim RS As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Password=sa;Initial Catalog=db_DY;Data Source=NIE" RS.CursorLocation = adUseClient
' RS.CursorType = adOpenStatic
cn.Open
If Trim(Text1.Text) <> "" Then
SQL = "SELECT * FROM tb_userinfo WHERE userid='" & Trim(Text1.Text) & "'"
Set RS = cn.Execute(SQL)
If RS.RecordCount > 0 Then
If Text2.Text = RS!pwd Then
MsgBox "登录成功!"
End If
Else
MsgBox "登录名错误,请确认"
Text1.Text = " "
End If
Else
MsgBox "请输入用户名"
End If
cn.Close
Set cn = Nothing
End Sub
Dim cn As ADODB.Connection
Dim SQL As String
Dim RS As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Password=sa;Initial Catalog=db_DY;Data Source=NIE" RS.CursorLocation = adUseClient
' RS.CursorType = adOpenStatic
cn.Open
If Trim(Text1.Text) <> "" Then
SQL = "SELECT * FROM tb_userinfo WHERE userid='" & Trim(Text1.Text) & "'"
Set RS = cn.Execute(SQL)
If RS.RecordCount > 0 Then
If Text2.Text = RS!pwd Then
MsgBox "登录成功!"
End If
Else
MsgBox "登录名错误,请确认"
Text1.Text = " "
End If
Else
MsgBox "请输入用户名"
End If
cn.Close
Set cn = Nothing
End Sub
解决方案 »
- VB6中如何让很多独立文本框中的某一个获得焦点时选中其全部内容
- 用winsock的大哥大姐大师们进
- mysql 企业管理器问题
- 菜鸟求助大虾 关于用户类型未定义问题
- 如何"Xor"两个字符串
- 自编程序打包安装后,程序运行一段时间后,他会自动关掉,无任何错误提示!请各位大侠提供宝贵参考意见,不然老板炒我了!!!
- 用vba将excel的数据写入ppt的图表中,但运行一段时间后,会狂加载graph.exe,没办法释放
- 报表中一个很难的问题,大虾们请进!up有分!!!
- 有关二进制文件的问题?
- 各位大虾:UDP是怎样进行连接的?
- 哪位能给提供一下逻辑坐标和设备坐标映射模式变换的源代码
- FTP连接使用MFTPX.OCX控件,GetFilenameList返回值为空的问题
要么设 cn.CursorLocation = adUseClient
要么用 rs.Open() 函数查询。
SQL = "SELECT * FROM tb_userinfo WHERE userid='" & Trim(Text1.Text) & "'"
if rs.state<>adstateclosed then rs.close
rs.open sql,cn,adopenkeyset,adlockreadonly
if rs.recordcount>0 then
....