|登录 |注册

查看: 5207|回复: 37
打印 上一主题 下一主题

关于VB带入textbox中的资料至mySQL的问题

[复制链接]
lord14383
2010-3-8 10:54 PM
小弟我遇到一点问题。。。
请各位大大帮帮忙,谢谢大大的合作^^
我在做VB带textbox资料输入进mySQL遇到问题

InvalidOperationException was unhandled
Unable to retrieve stored procedure metadata.  Either grant  SELECT privilege to mysql.proc for this user or use "use procedure bodies=false" with  your connection string.

以下是我所写的
Dim SpCmd As MySqlCommand
        SpCmd = New MySqlCommand("P", myConnection)
        SpCmd.CommandType = CommandType.StoredProcedure
        Dim MyReader As MySqlDataReader = SpCmd.ExecuteReader
        While MyReader.Read
            Console.Write(MyReader.GetChar(0))
            Console.WriteLine(MyReader.GetInt32(1))
            Console.WriteLine(MyReader.GetChar(2))
            Console.WriteLine(MyReader.GetChar(3))
        End While
        MyReader.Close()

以下是我在mySQL所新建procedure
create procedure P
(
parm1 varchar(40),
parm2 int(11),
parm3 varchar(40),
parm4 varchar(11)
)
Select Name,Age,Email,TEL
FROM employee;

为什么一定要用procedure才可以将textbox中的资料带入mySQL?

小弟我真的不是很懂vb 连接mySQL的,我买了书回来我就只好找着试试看,因为我什么都不会。。。
希望大大能够帮帮小弟我。。。
我上google搜索了还是没有答案,它们只说他们遇到的问题,而没有放如何解决
Super-Tomato
2010-3-9 12:29 AM
原帖由 lord14383 于 2010-3-8 10:54 PM 发表
小弟我遇到一点问题。。。
请各位大大帮帮忙,谢谢大大的合作^^
我在做VB带textbox资料输入进mySQL遇到问题

InvalidOperationException was unhandled
Unable to retrieve stored procedure metadata.  E ...


可以到 mysql 官網下載 odbc 連接上資料庫後就可以直接使用 sql 指令了
goodday
2010-3-9 12:53 AM
用 mysql 官方的 library
http://www.mysql.com/downloads/connector/net/6.2.html

回复 #2 Super-Tomato 的帖子 #3 goodday 的帖子

lord14383
2010-3-9 01:11 AM
谢谢你们的回复^^
我已经安装了Connector可是还是跟之前一样(其实我之前就已经安装了connector,只不过我换成新版本的)
现在的问题是:MySqlException was unhandled
SELECT command denied to user "@'localhost' for table 'proc'
好象还是一样,大大有遇到过这种问题吗?

回复 #4 lord14383 的帖子

宅男-兜着走
2010-3-9 02:03 AM
用 mysql connector 的 mysqlHelper
mysql 的网站能下载。
而且有说一定要 sp 吗? 没sp 一样能沟通 啊。


你的error message 我看过, 不过我的是 database 的名字打错, 跟 table 名打错。 debug 了半天。
Super-Tomato
2010-3-9 12:35 PM
原帖由 lord14383 于 2010-3-9 01:11 AM 发表
谢谢你们的回复^^
我已经安装了Connector可是还是跟之前一样(其实我之前就已经安装了connector,只不过我换成新版本的)
现在的问题是:MySqlException was unhandled
SELECT command denied to user "@'localhost' for table 'proc'



權限問題, 而且沒有指定 username 和 password

回复 #5 宅男-兜着走 的帖子 #6 Super-Tomato 的帖子

lord14383
2010-3-9 02:09 PM
谢谢你们的回复^^
我弄到了^^
无论怎样还是要谢谢你们^^

我现在又有另一个问题,希望大大能够帮帮小弟我^^
DataGridView 如何加入多一行的呢?好乱哦,我上google看了还是看不懂。。。。
我试了还是不可以,是不是我用错东西来储存帐单了呢?
lord14383
2010-3-9 03:48 PM
我在DataGridView中找到了AllowUsersToAddRows=True,可是为什么还是没有心号让我加多一行?
lord14383
2010-3-10 04:45 PM
For a = 0 To counter

            Dim SelectText As String
            Dim SelectStatement As MySqlCommand
            Dim SelectReader As MySqlDataReader
            SelectText = " SELECT * FROM orderform1 where No=" + (a + 1).ToString + ";"
            SelectStatement = New MySqlCommand(SelectText, myConnection)
            SelectReader = SelectStatement.ExecuteReader()
            While (SelectReader.Read())

                MessageBox.Show(SelectReader.GetInt32(0).ToString + " " + SelectReader.GetInt32(1).ToString + " " + SelectReader.GetString(2).ToString + " " + SelectReader.GetInt32(3).ToString + " " + SelectReader.GetInt32(4).ToString + " " + SelectReader.GetInt32(5).ToString)
                'Me.DataGridView1.Item(0, i - 1).Value = SelectReader.GetInt32(0)
                'Me.DataGridView1.Item(1, i - 1).Value = SelectReader.GetInt32(1)
                'Me.DataGridView1.Item(2, i - 1).Value = SelectReader.GetString(2)
                'Me.DataGridView1.Item(3, i - 1).Value = SelectReader.GetInt32(3)
                'Me.DataGridView1.Item(4, i - 1).Value = SelectReader.GetInt32(4)
                'Me.DataGridView1.Item(5, i - 1).Value = SelectReader.GetInt32(5)


            End While
            SelectReader.Close()
            a = a + 1
        Next
为什么只执行一次呢?
明明我有用for loop了,为什么。。。。。
真的很奇怪。。。。。
Super-Tomato
2010-3-10 05:37 PM
原帖由 lord14383 于 2010-3-10 04:45 PM 发表
For a = 0 To counter

            Dim SelectText As String
            Dim SelectStatement As MySqlCommand
            Dim SelectReader As MySqlDataReader
            SelectText = " SELECT * FROM orderform1 where No=" + (a + 1).ToString + ";"
            SelectStatement = New MySqlCommand(SelectText, myConnection)
            SelectReader = SelectStatement.ExecuteReader()
            While (SelectReader.Read())

                MessageBox.Show(SelectReader.GetInt32(0).ToString + " "+ SelectReader.GetInt32(1).ToString + " " +SelectReader.GetString(2).ToString + " " +SelectReader.GetInt32(3).ToString + " " +SelectReader.GetInt32(4).ToString + " " +SelectReader.GetInt32(5).ToString)
                'Me.DataGridView1.Item(0, i - 1).Value = SelectReader.GetInt32(0)
                'Me.DataGridView1.Item(1, i - 1).Value = SelectReader.GetInt32(1)
                'Me.DataGridView1.Item(2, i - 1).Value = SelectReader.GetString(2)
                'Me.DataGridView1.Item(3, i - 1).Value = SelectReader.GetInt32(3)
                'Me.DataGridView1.Item(4, i - 1).Value = SelectReader.GetInt32(4)
                'Me.DataGridView1.Item(5, i - 1).Value = SelectReader.GetInt32(5)


            End While
            SelectReader.Close()
            a = a + 1
        Next
为什么只执行一次呢?
明明我有用for loop了,为什么。。。。。
真的很奇怪。。。。。



為何 a 不是依照 looping 递增?
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2026-1-2 04:37 AM , Processed in 0.094759 second(s), 26 queries .

Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.

本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved

Dedicated Server powered by iCore Technology Sdn. Bhd.

合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部