Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 4456|回复: 37
打印 上一主题 下一主题

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

[复制链接]

7

主题

0

好友

1098

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

跳转到指定楼层
1#
发表于 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搜索了还是没有答案,它们只说他们遇到的问题,而没有放如何解决




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 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 指令了


回复

使用道具 举报

13

主题

0

好友

2113

积分

白金长老

Rank: 10

3#
发表于 2010-3-9 12:53 AM |只看该作者
回复

使用道具 举报

7

主题

0

好友

1098

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

4#
发表于 2010-3-9 01:11 AM |只看该作者

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

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


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

5#
发表于 2010-3-9 02:03 AM |只看该作者

回复 #4 lord14383 的帖子

用 mysql connector 的 mysqlHelper
mysql 的网站能下载。
而且有说一定要 sp 吗? 没sp 一样能沟通 啊。


你的error message 我看过, 不过我的是 database 的名字打错, 跟 table 名打错。 debug 了半天。


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

6#
发表于 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


回复

使用道具 举报

7

主题

0

好友

1098

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

7#
发表于 2010-3-9 02:09 PM |只看该作者

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

谢谢你们的回复^^
我弄到了^^
无论怎样还是要谢谢你们^^

我现在又有另一个问题,希望大大能够帮帮小弟我^^
DataGridView 如何加入多一行的呢?好乱哦,我上google看了还是看不懂。。。。
我试了还是不可以,是不是我用错东西来储存帐单了呢?


回复

使用道具 举报

7

主题

0

好友

1098

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

8#
发表于 2010-3-9 03:48 PM |只看该作者
我在DataGridView中找到了AllowUsersToAddRows=True,可是为什么还是没有心号让我加多一行?


回复

使用道具 举报

7

主题

0

好友

1098

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

9#
发表于 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了,为什么。。。。。
真的很奇怪。。。。。


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

10#
发表于 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, 2024-10-25 05:30 PM , Processed in 0.122647 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部