Dim dt2 As system.data.DataTable = db.ExecuteDataSet(Sql2).Tables(0)
dt2.TableName = "mx_b"
Dim t2 As Table = e.Form.Controls("Table2").Table
t2.datasource = dt2.Copy
问题1:上面代码每句代表什么意思?
问题2:db.ExecuteDataSet(Sql2).Tables(0)中的Tables(0)与Controls("Table2").Table中("Table2")的名称是否要一样?
把执行sql返回的表格表单到Table2控件
Tables(0)指的是.net的datatable表格,一般对应数据库表名称
"Table2"指的是foxtable的表控件,和Tables(0)不是一回事。名称可以不一样
没报错
Dim db = HySq-l.DataBaseFactory.CreateDatabase("mxc")
Dim Sq-l = "selec-t * from b3
Dim dt As system.data.DataTable = db.ExecuteDataSet(Sq-l).Tables(0)
dt.TableName = "b3 "
Dim t As Table = e.Form.Controls("Table1").Table
t.datasource = dt.Copy
Dim Sq-l2 = "selec-t * from b2 ;"
Dim dt2 As system.data.DataTable = db.ExecuteDataSet(Sq-l2).Tables(0)
dt2.TableName = "b2"
Dim t2 As Table = e.Form.Controls("Table2").Table
t2.datasource = dt2.Copy
下面报错:未将对象引用设置到对象的实例。
注:"b3","b2"是数据库的表名
Dim db = HySq-l.DataBaseFactory.CreateDatabase("mxc")
Dim Sq-l = "selec-t * from b3
Dim dt As system.data.DataTable = db.ExecuteDataSet(Sq-l).Tables("b3")
'dt.TableName = "b3 "
Dim t As Table = e.Form.Controls("Table1").Table
t.datasource = dt.Copy
Dim Sq-l2 = "selec-t * from b2 ;"
Dim dt2 As system.data.DataTable = db.ExecuteDataSet(Sq-l2).Tables("b2")
'dt2.TableName = "b2"
Dim t2 As Table = e.Form.Controls("Table2").Table
t2.datasource = dt2.Copy
Tables(0)指的是.net的datatable表格,一般对应数据库表名称
"Table2"指的是foxtable的表控件,和Tables(0)不是一回事。名称可以不一样