以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于MYSQL (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=158418) |
-- 作者:blackzhu -- 发布时间:2020/11/19 14:54:00 -- 关于MYSQL 我封装了一个mysql的函数 Public Shared Function ExecuteReader(ByVal sql As String, ParamArray ps As MySqlParameter()) As MySqlDataReader Using conn As MySqlConnection = CreateConnection() Using cmd As MySqlCommand = conn.CreateCommand() cmd.CommandText = sql If ps IsNot Nothing Then cmd.Parameters.AddRange(ps) End If Return cmd.ExecuteReader() End Using End Using End Function 我用VS窗口是 可以获取数据的 但是我放到BS接口中获取不了数据 Dim page As Integer = 0 Dim pageRows As Integer If e.Values.ContainsKey("page") Then \'如果地址中有page参数 Integer.TryParse(e.Values("page"), page) \'提取page参数 page = e.Values("page") - 1 End If If e.Values.ContainsKey("limit") Then \'如果地址中有page参数 Integer.TryParse(e.Values("limit"), pageRows) \'提取page参数 pageRows = e.Values("limit") End If Dim StartRow As Integer = page * pageRows \'此页第一行 Dim EndRow As Integer = (page + 1) * pageRows Dim SqlText As String = "sel ect id,username from sys_user where id=?id ORDER BY id LIMIT " & StartRow & "," & EndRow Dim pars As MySqlParameter() = {New MySqlParameter("?id", MySqlDbType.String)} pars(0).Value = "0000919b63324fdfb29c78623fdcb4bf" Dim sdr As MySqlDataReader sdr = MySqlHelper.ExecuteReader(SqlText, pars) Output.Show(sdr.FieldCount) 获取不了 Output.Show(sdr.Getname(0)) 获取不了 这个代码有啥问题? |
-- 作者:有点蓝 -- 发布时间:2020/11/19 15:02:00 -- 到vs里调试能不能进入函数? |
-- 作者:blackzhu -- 发布时间:2020/11/19 15:05:00 -- 以下是引用有点蓝在2020/11/19 15:02:00的发言: 到vs里调试能不能进入函数? 我用VS窗口用了这个函数 Public Shared Function ExecuteDataTable(ByVal sql As String, ParamArray ps As MySqlParameter()) As DataTable Dim table As DataTable = New DataTable() Using conn As MySqlConnection = CreateConnection() Using cmd As MySqlCommand = conn.CreateCommand() cmd.CommandText = sql If ps IsNot Nothing Then cmd.Parameters.AddRange(ps) End If Using adapter As MySqlDataAdapter = New MySqlDataAdapter(cmd) adapter.Fill(table) End Using Return table End Using End Using End Function 执行代码 Dim SqlText As String = "sel ect id,username from sys_user where id=?id" Dim pars As MySqlParameter() = {New MySqlParameter("?id", MySqlDbType.String)} pars(0).Value = "0000919b63324fdfb29c78623fdcb4bf" Dim dt As System.Data.DataTable = New System.Data.DataTable() dt = MySqlHelper.ExecuteDataTable(SqlText, pars) Me.DataGridView1.DataSource = dt 没有任何问题,但是这个函数在接口中同样获取不了数据 Dim SqlText As String = "sel ect id,username from sys_user where id=?id ORDER BY id LIMIT " & StartRow & "," & EndRow output.show(SqlText) 到这边还正常,往下就没反应了 |
-- 作者:有点蓝 -- 发布时间:2020/11/19 15:29:00 -- Dim SqlText As String = "sel ect id,username from sys_user where id=?id ORDER BY id LIMIT " & StartRow & "," & EndRow output.show(SqlText) Dim pars As MySqlParameter() = {New MySqlParameter("?id", MySqlDbType.String)} output.show("这里能不能显示?") pars(0).Value = "0000919b63324fdfb29c78623fdcb4bf" Dim sdr As MySqlDataReader sdr = MySqlHelper.ExecuteReader(SqlText, pars) Output.Show(sdr.FieldCount) 获取不了 Output.Show(sdr.Getname(0)) 获取不了 |
-- 作者:blackzhu -- 发布时间:2020/11/19 15:35:00 -- 老大 不知道为啥 这个断点调试没有用,但是用狐表窗口的话就立马可以,很奇怪 |
-- 作者:逛逛 -- 发布时间:2020/11/19 15:38:00 -- 如果是传DATATable 要有命名 |
-- 作者:blackzhu -- 发布时间:2020/11/19 15:53:00 -- 犯了一个低级错误 没有把dll 外部引用 |
-- 作者:浙江仔 -- 发布时间:2020/11/19 16:34:00 -- dll分享下呗 |
-- 作者:blackzhu -- 发布时间:2020/11/19 17:19:00 -- 以下是引用浙江仔在2020/11/19 16:34:00的发言: dll分享下呗 你要哪个dll mysql.data的?
|
-- 作者:浙江仔 -- 发布时间:2020/11/19 20:01:00 -- 你的mysql的函数,可以添加mysql数据源使用吗? [此贴子已经被作者于2020/11/19 20:03:56编辑过]
|