以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]请教这段代码问题在哪?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=29720)

--  作者:zcw2764
--  发布时间:2013/3/12 13:34:00
--  [求助]请教这段代码问题在哪?

Dim dt As DataTable
Dim cmd As New SQLCommand
Dim filter As String
cmd.ConnectionName = _DBSource1
Filter = "[一级单位] = \'" & _userDW1 & "\' and [三级单位] = \'" & _userDW3 & "\'"
cmd.CommandText = "SELECT  工作证号 as 工号,姓名,一级单位,二级单位,三级单位 From {人资_职工信息} where " & filter & " "
dt = cmd.ExecuteReader()
dt.DataCols.Add("选择", Gettype(Boolean))
Tables(e.form.name & "_table1").datasource = dt
Tables(e.form.name & "_table1").autosizecols()
Tables(e.form.name & "_table1").AllowEdit = True

这段代码运行时出现图提示

图片内容为“不存在名为""的datatable

[此贴子已经被作者于2013-3-12 13:37:40编辑过]

--  作者:狐狸爸爸
--  发布时间:2013/3/12 13:39:00
--  

看不到你的图,一般来说都是你的表名错了。

你用这个方法,判断一下是哪一行代码出错了:

 

http://www.foxtable.com/help/topics/1485.htm