Private Sub Command1_Click() rs.MoveFirst
rs.Find "用户名 like '" & Text1 & "'" If Text1.Text = "" Then
MsgBox "请输入用户名", 48, "信息提示"
Text1.SetFocus
Else
If UCase(Text1.Text) = UCase(rs("用户名")) Then
MsgBox "用户名已存在", 48, "警告提示"
Text1.Text = ""
Text1.SetFocus
Else
If Text2.Text = "" Then
MsgBox "请输入密码", 48, "信息提示"
Text2.SetFocus
Else
If Text3.Text <> Text2.Text Then
MsgBox "密码与确认密码不符", 48, "信息提示"
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
SendKeys "{Home}+{End}"
Else
If Combo1.Text = "" Then
MsgBox "请您选择权限", 48, "信息提示"
Combo1.SetFocus
Else
If (login.Combo1 = "高级用户") And (Combo1 <> "普通用户") Then
MsgBox "您只能添加普通用户", 48, "信息提示"
Combo1.SetFocus
Else
If rs.EOF = False Then
rs.AddNew
rs("用户名") = Text1.Text
rs("密码") = Text2.Text
rs("权限") = Combo1.Text
rs.Update
MsgBox "添加成功", 64, "信息提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
End If
End If
End If
End If
End If
End If
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load() On Error GoTo Err
rs.MoveFirst
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from 用户", cnn1, 1, 3
Set chexing.DataGrid1.DataSource = rs
Err:
If Err.Number = 3021 Then
logininfo = 0
Else: logininfo = 1
End IfEnd Sub
rs.MoveFirst 处报错 数据库已连接
我查不出来哪有错 请各位大虾帮帮忙
rs.Find "用户名 like '" & Text1 & "'" If Text1.Text = "" Then
MsgBox "请输入用户名", 48, "信息提示"
Text1.SetFocus
Else
If UCase(Text1.Text) = UCase(rs("用户名")) Then
MsgBox "用户名已存在", 48, "警告提示"
Text1.Text = ""
Text1.SetFocus
Else
If Text2.Text = "" Then
MsgBox "请输入密码", 48, "信息提示"
Text2.SetFocus
Else
If Text3.Text <> Text2.Text Then
MsgBox "密码与确认密码不符", 48, "信息提示"
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
SendKeys "{Home}+{End}"
Else
If Combo1.Text = "" Then
MsgBox "请您选择权限", 48, "信息提示"
Combo1.SetFocus
Else
If (login.Combo1 = "高级用户") And (Combo1 <> "普通用户") Then
MsgBox "您只能添加普通用户", 48, "信息提示"
Combo1.SetFocus
Else
If rs.EOF = False Then
rs.AddNew
rs("用户名") = Text1.Text
rs("密码") = Text2.Text
rs("权限") = Combo1.Text
rs.Update
MsgBox "添加成功", 64, "信息提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
End If
End If
End If
End If
End If
End If
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load() On Error GoTo Err
rs.MoveFirst
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from 用户", cnn1, 1, 3
Set chexing.DataGrid1.DataSource = rs
Err:
If Err.Number = 3021 Then
logininfo = 0
Else: logininfo = 1
End IfEnd Sub
rs.MoveFirst 处报错 数据库已连接
我查不出来哪有错 请各位大虾帮帮忙
解决方案 »
- 请教一下,如何把这样的字符串转换成日期。
- 将 nvarchar 值 ' select @maxpoint=max(分数) from 问答题 where 分数< ' 转换为数据类型为 int 的列时发生语法错误。
- 请大侠再次出招,我只剩下最后10分了
- 一个极简单的问题
- 中文排序的问题,求助!
- 兄弟们,可能是很菜的问题,答对马上给分
- 怎样让不同用户同时修改同一个表
- 救命,sql 语句
- SQL Server可以实现以下功能吗?更新M个字段,当字段原有值<N时,用N代替,当>=N时保留原有值。
- sybase中生成的SQL语句在MS SQL中执行,须不须要转化???
- 到底什么事存储过程。一般怎么用啊??
- 问一个多表查询的问题
dim server string,pwd string,db string
string=服务器名
pwd=登录密码
db=数据库名
On Error GoTo ErrorHandler
Set myConn = New ADODB.Connection
'设置连接
myConn.ConnectionString = "driver={SQL Server};" & _
"server=" & Server & ";uid=sa;pwd=" & pwd & ";database=" & db
myConn.Open
'连接成功
'这里添加获得数据的语句 Exit SubErrorHandler:
MsgBox "连接出错,请检查服务器名及密码是否正确。", vbOKOnly, "连接错误"
已经有这些代码了 也连上了 只不过那个是在另一个名叫login的窗体中显示的 那里面不存在我要解决的问题 所以没贴出来
可是错误不是在这儿出的 我分步调试了 错误出在click里
rs.movefirst
有错了.而不是 Command1_click事件中的语句错.
我把load里的rs.movefirst删了 但是出现: 对象关闭时 不允许操作 我确定我没有关闭记录或者连接