以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 访问MySQL如何读取数据? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=100859) |
-- 作者:l20j07 -- 发布时间:2017/5/19 18:14:00 -- 访问MySQL如何读取数据? MySqlDataReader返回的数据是什么东西?如何写到表格里面?我用总是显示sdr[0]无法转换为字符串!!!! |
-- 作者:有点蓝 -- 发布时间:2017/5/19 20:31:00 -- 参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=100450&skin=0 |
-- 作者:l20j07 -- 发布时间:2017/5/19 20:56:00 -- Table("表A").DataSource = cmd.ExecuteReader() 会报错 Tables("表A").DataSource = cmd.ExecuteReader() 没有反应,数据并没有被读出来
|
-- 作者:有点蓝 -- 发布时间:2017/5/19 21:12:00 -- Dim conn As MySql.Data.MySqlClient.MySqlConnection Dim cmd As MySql.Data.MySqlClient.MySqlCommand Dim dt As DataTable Dim connStr As String = "server=" + Vars("zw_ip") + "; port=3306; user id=root; password=Aa1234qwer; database=zdjks; Allow Zero Datetime=True" conn = New MySql.Data.MySqlClient.MySqlConnection(connStr) conn.Open Dim sql = "sele ct adminssionid,cardid from examinee where ordid= \'" & oid & "\' " Dim mda As New MySql.Data.MySqlClient.MySQLDataAdapter(sql, conn) Dim ds As New System.Data.DataSet() mda.Fill(ds, "table1") Tables("表A").DataSource = ds.Tables("table1")
|
-- 作者:l20j07 -- 发布时间:2017/5/19 21:25:00 -- 还是不行,表A是默认的主表么? Table1 又是什么? 下面是我的代码 Dim conn As MySql.Data.MySqlClient.MySqlConnection Dim cmd As MySql.Data.MySqlClient.MySqlCommand Dim sdr As MySql.Data.MySqlClient.MySqlDataReader Dim dt As DataTable Dim ii,jj,kk As Integer Dim connStr As String = "server=localhost; port=3306; user id=root; password= ; database=mytt" conn = New MySql.Data.MySqlClient.MySqlConnection(connStr) conn.Open Dim mda As New MySql.Data.MySqlClient.MySQLDataAdapter(e.Form.Controls("TextBox2").text, conn) Dim ds As New System.Data.DataSet() mda.Fill(ds, "table1") Tables("表A").DataSource = ds.Tables("table1") conn.close()
|
-- 作者:有点蓝 -- 发布时间:2017/5/19 21:38:00 -- 做个窗口,放一个表控件和一个按钮,按钮事件 Dim conn As MySql.Data.MySqlClient.MySqlConnection Dim cmd As MySql.Data.MySqlClient.MySqlCommand Dim sdr As MySql.Data.MySqlClient.MySqlDataReader Dim dt As DataTable Dim ii,jj,kk As Integer Dim connStr As String = "server=localhost; port=3306; user id=root; password= ; database=mytt" conn = New MySql.Data.MySqlClient.MySqlConnection(connStr) conn.Open Dim mda As New MySql.Data.MySqlClient.MySQLDataAdapter(e.Form.Controls("TextBox2").text, conn) Dim ds As New System.Data.DataSet() mda.Fill(ds, "table1") e.form.controls("Table1").Table.DataSource = ds.Tables("table1") conn.close() 还不行,检查你sql有没有数据
|
-- 作者:l20j07 -- 发布时间:2017/5/19 21:40:00 -- 刚刚试了,现在可以了,就是“表A”的问题,谢谢啦! |