以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] 代码错误求解 ~~~~~~~~~~~~~~~~~~~~~ (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=34420) |
-- 作者:zhl7928 -- 发布时间:2013/6/7 11:46:00 -- [求助] 代码错误求解 ~~~~~~~~~~~~~~~~~~~~~ Dim b As String = e.Form.Controls("用户名输入框").value Dim c As String = e.Form.Controls("密码输入框").value Dim d As String = e.Form.Controls("用户角色输入框").value Dim r As String = Tables("用户管理_用户管理").Current("用户名称") Dim s As String = Tables("用户管理_用户管理").Current("用户角色") If b = "" Then MessageBox.Show("请输入用户名","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If c = "" Then MessageBox.Show("请输入密码","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If e.Form.Controls("密码确认框").value = "" Then MessageBox.Show("请确认密码","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If d = "" Then MessageBox.Show("请初步确定用户权限级别","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If c.length < 6 Then MessageBox.Show("密码长度不得小于6位","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If c.length > 16 Then MessageBox.Show("密码长度不得超过16位","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If If e.Form.Controls("密码确认框").value <> c Then MessageBox.Show("2次输入的密码不相同","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If Dim a As new SQLCommand a.C MessageBox.show(b) MessageBox.show(c) MessageBox.show(d) MessageBox.show(r) MessageBox.show(s) If d <> s Then Dim pp() As String = d.Split(",") a.CommandText = "Select * from {权限表}" Dim y As DataTable = a.ExecuteReader(True) For Each qq As DataRow In y.DataRows For Each p As String In pp If qq(p) = True Then qq(r) = True Exit For End If Next Next y.save() End If If b = r Then a.CommandText = "Select Count(*) From {用户} Where 用户名称 = \'" & b & "\'" Dim t As DataTable = a.ExecuteReader(True) t.DataRows(0)("用户密码") = c t.save() Else a.CommandText = "Select Count(*) From {用户} Where 用户名称 = \'" & r & "\'" Dim u As DataTable = a.ExecuteReader(True) u.DataRows(0)("用户密码") = c If d <> s Then u.DataRows(0)("用户角色") = d End If Dim Builder As New ADOXBuilder("new") Builder.Open() With Builder.Tables("权限表") .RenameColumn(r,b) End With Builder.Close() u.save()
|
-- 作者:狐狸爸爸 -- 发布时间:2013/6/7 11:52:00 -- 错误提示是ExcuteReader执行出错,可以自己分析一下上面的代码,看看哪一个ExcuteReadr执行出错,然后获取合成的select语句,到sql执行窗口执行,测试分析。 |
-- 作者:Bin -- 发布时间:2013/6/7 11:54:00 -- 应该是这段代码的问题 a.CommandText = "Select Count(*) From {用户} Where 用户名称 = \'" & b & "\'" Dim t As DataTable = a.ExecuteReader(True) t.DataRows(0)("用户密码") = c t.save() a.CommandText = "Select Count(*) From {用户} Where 用户名称 = \'" & r & "\'" Dim u As DataTable = a.ExecuteReader(True) u.DataRows(0)("用户密码") = c If d <> s Then u.DataRows(0)("用户角色") = d End If 你删除看看 如果你设置为a.ExecuteReader(True) 应该就无法使用这种查询表 Select Count(*) From {用户} Where 用户名称 = \'" & r & "\'"
|
-- 作者:zhl7928 -- 发布时间:2013/6/7 12:09:00 -- 我晕,怎么用上这句了~ 尴尬 谢谢
是查询语句错误 |