以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 这个代码错在哪里了么?请前辈们指点一下 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=55167) |
||||
-- 作者:jinzhengbe -- 发布时间:2014/8/12 9:34:00 -- 这个代码错在哪里了么?请前辈们指点一下 Dim UserName As String = e.Form.Controls("UserName").Value Dim cmd As New SQLCommand Dim dt As DataTable Dim dr As DataRow cmd.C If UserName = "" Then Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If cmd.CommandText = "Select * From {newmoo_User} Where [userName] = \'" & UserName & "\'" dt = cmd.ExecuteReader If dt.DataRows.Count = 0 Then Messagebox.show("此用户不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If dr = dt.DataRows(0) If System.Web.Security.FormsAuthentication.HashpasswordForStoringInConfigFile(e.Form.Controls("password").Value, "MD5") = dr("password").Trim() Then _UserName = username _UserGroup = dr("Group") e.Form.Close Else Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) End If Dim dr1 As DataRow dr1 = DataTables("users").Find("id= " & "\'" ) If dr1 IsNot Nothing \'如果找到, 则设置各列内容 dr("业务员")= dr1("username") Else End If DataTables("订单").LoadFilter = "业务员 = \'" & _UserName & "\'" DataTables("订单").Load()
|
||||
-- 作者:有点甜 -- 发布时间:2014/8/12 9:36:00 -- 什么错误提示?
这段什么意思
Dim dr1 As DataRow dr1 = DataTables("users").Find("id= " & "\'" )
|
||||
-- 作者:Bin -- 发布时间:2014/8/12 9:36:00 -- 请问出现什么问题? |
||||
-- 作者:jinzhengbe -- 发布时间:2014/8/12 9:49:00 -- 我的想法是,在user这个表里找 到 id列 和 订单 表 的 leaderid 是一样的 然后用 user 表里的 username 来 填充 订单 表的 业务员列
|
||||
-- 作者:有点甜 -- 发布时间:2014/8/12 9:56:00 -- 从你的代码
1、你的dr没有赋值为对应的行;
2、 dr1 = DataTables("users").Find("id= " & "\'" ) 明显有问题
3、不懂你说的逻辑。请上传例子 |
||||
-- 作者:jinzhengbe -- 发布时间:2014/8/12 10:31:00 -- 用户名mingxing 密码1234 |
||||
-- 作者:有点甜 -- 发布时间:2014/8/12 10:33:00 -- 例子发上来,说明意图。 |
||||
-- 作者:jinzhengbe -- 发布时间:2014/8/12 10:48:00 -- 默认 订单表里的 业务员 列是空的 所以想从 user表 调用 数据 即 user表的 username =订单表的 业余员 这样 每个客户才能看到自己相应的订单
|
||||
-- 作者:有点甜 -- 发布时间:2014/8/12 10:59:00 -- 那就不需要写代码啊,直接这句就行
DataTables("订单").LoadFilter = "业务员 = \'" & _UserName & "\'" |
||||
-- 作者:有点甜 -- 发布时间:2014/8/12 11:04:00 -- 如果是根据id和leaderid加载,就这样写
Dim dr1 As DataRow = DataTables("users").Find("username = \'" & _UserName & "\'" ) |