Private Sub Command1_Click()
Dim mrc As New ADODB.Recordset
'txtsql = " select * from oper where 用户名= '" & Trim$(Text1(0).Text) & " ' and 口令= ' " & Trim$(Text1(1).Text) + " ' "
txtsql = " select * from oper where 用户名= '1111' and 口令= '1111' " 'Text2.Text = txtsql
Set mrc = exesql(txtsql)
If mrc.RecordCount = 0 Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox "没有该用户,继续登陆", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已登陆失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"
mcr.Close
Unload Me
End If
Else '找到合法用户
userlevel = Trim(mrc.Fields("级别"))
mrc.Close
Unload Me
menu.Show '调用主界面窗体
End If
End Sub
调试时老说没有用户什么什么的小菜鸟 有点郁闷啊
Dim mrc As New ADODB.Recordset
'txtsql = " select * from oper where 用户名= '" & Trim$(Text1(0).Text) & " ' and 口令= ' " & Trim$(Text1(1).Text) + " ' "
txtsql = " select * from oper where 用户名= '1111' and 口令= '1111' " 'Text2.Text = txtsql
Set mrc = exesql(txtsql)
If mrc.RecordCount = 0 Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox "没有该用户,继续登陆", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已登陆失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"
mcr.Close
Unload Me
End If
Else '找到合法用户
userlevel = Trim(mrc.Fields("级别"))
mrc.Close
Unload Me
menu.Show '调用主界面窗体
End If
End Sub
调试时老说没有用户什么什么的小菜鸟 有点郁闷啊
解决方案 »
- 运行时发生错误 429,ActiveX控件无法创建
- 在WIN98下不能使用ADODC控件
- 在VB中如何用代碼進行注冊dll文件
- 对MSComm收到的数据使用Replace遇到的问题
- 如何用winsock进行网络传输
- 请问我想在listbox里面随记录动态添加三个checkbox,怎么实现?
- 字符串转换为日期类型
- 如何去掉按钮上面的虚框
- 接上次问题,不会VB的别进来。
- 在上网浏览时,如何获得一篇文章的标题。我知道有一个API函数可以获得某个窗体的标题,但有些窗体的标题与文章的标题并不一致,请问如何解决,谢谢。
- 有关vb的问题
- 开贴感谢PctGL帮我解决不能访问文件名中有Unicode字符的问题2
sql = Trim$(sql)
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conn.ConnectionString = "dsn=KS;uid=MICROSOF-45B405;pwd=;"
conn.Open
Set rst.ActiveConnection = conn
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open sql
Set exesql = rst
Set exesql = Nothing '释放记录
Set conn = Nothing '释放连接End Function
第一句是不是啊
sql = Trim$(sql)
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conn.ConnectionString = "dsn=KS;uid=MICROSOF-45B405;pwd=;"
conn.Open
Set rst.ActiveConnection = conn
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open sql
Set exesql = rst
Set rst = Nothing '释放记录
Set conn = Nothing '释放连接 End Function
Private Sub Command1_Click()
Dim mrc As New ADODB.Recordset
'txtsql = " select * from oper where 用户名= '" & Trim$(Text1(0).Text) & " ' and 口令= ' " & Trim$(Text1(1).Text) + " ' "
txtsql = " select * from oper where 用户名= '1111' and 口令= '1111' " 'Text2.Text = txtsql
Set mrc = exesql(txtsql)
If mrc.RecordCount = 0 Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox "没有该用户,继续登陆", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已登陆失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"
mcr.Close
Unload Me
End If
Else '找到合法用户
userlevel = Trim(mrc.Fields("级别"))
mrc.Close 还显示这里有问题的啊
Unload Me
menu.Show '调用主界面窗体
End If
End Sub
Dim micount As Integer
Private Sub Command1_Click()
Dim txtSql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
UserName = "" '这是个全局变量
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSql = "select * from financer where 用户名='" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSql, msgtext) '这个ExecuteSQL也是个自定义的函数
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields("密码")) = Trim(txtpassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtpassword.SetFocus
txtpassword.Text = ""
End If
End If
End If
micount = micount + 1
If micount = 3 Then
Me.Hide
End If
End Sub
Private Sub Command1_Click()
Dim mrc As New ADODB.Recordset
'txtsql = " select * from oper where 用户名= '" & Trim$(Text1(0).Text) & " ' and 口令= ' " & Trim$(Text1(1).Text) + " ' "
txtsql = " select * from oper where 用户名= '1111' and 口令= '1111' " 'Text2.Text = txtsql
Set mrc = exesql(txtsql)
If mrc.eof or mrc.bof Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox "没有该用户,继续登陆", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已登陆失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"
mcr.Close
Unload Me
End If
Else '找到合法用户
userlevel = Trim(mrc.Fields("级别"))
mrc.Close
Unload Me
menu.Show '调用主界面窗体
End If
End Sub
这是我常用的操作数据库的代码,你看看对你有用否。