473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem passing a parameter in a MySQL stored procedure in VB.NET

Hi,

I've wrote a stored procedure which expects a parameter to be passed in on the WHERE clause for channelID. The stored procedure runs fine in Navicat for MySQL when you specify the parameter value in the popup prompt when you run it but when trying to use parameter.add in my VB.NET file it brings back the error:

'ERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.45-community-nt]Incorrect number of arguments for PROCEDURE mrluckybags.sp_select_test; expected 1, got 0'

which breaks at the line "adapter.Fill(dtReturn)"

The stored procedure and VB code are below:

DELIMITER $$

DROP PROCEDURE IF EXISTS `mydatabase`.`sp_select_test`$$
CREATE DEFINER=`root`@`%` PROCEDURE `mydatabase`.`sp_select_test`(channelID INT)
select store_channels.Name, store_categories.Name, store_products.*
FROM store_channels, store_categories, store_products
where store_channels.CHID = channelID
and store_categories.CAID = 1
and store_products.Status = 'VISIBLE'
END $$

DELIMITER ;



Dim MyConnection As New OdbcConnection(System.Configuration.ConfigurationM anager.AppSettings("connStr"))
Dim adapter As New OdbcDataAdapter
Dim dtReturn As New DataSet
MyConnection.Open()

Using oCmd As New OdbcCommand("{call sp_select_test}", MyConnection)
oCmd.CommandType = CommandType.StoredProcedure
oCmd.Parameters.Add("channelID", OdbcType.Int).Value = 1
adapter.SelectCommand = oCmd
adapter.Fill(dtReturn)
End Using
rptProducts.DataSource = dtReturn
rptProducts.DataBind()
MyConnection.Close()



Thanks in advance
Apr 1 '08 #1
2 4381
balabaster
797 Expert 512MB
Try this:

Dim oCmd As New OdbcCommand("{call sp_select_test}", MyConnection)
oCmd.CommandType = CommandType.StoredProcedure
oCmd.Parameters.Add(New OdbcParameter("channelID", 1))
adapter.SelectCommand = oCmd
adapter.Fill(dtReturn)
Apr 1 '08 #2
I tried that balabaster but it returns the same error. Any other suggestions?

Many thanks



Try this:

Dim oCmd As New OdbcCommand("{call sp_select_test}", MyConnection)
oCmd.CommandType = CommandType.StoredProcedure
oCmd.Parameters.Add(New OdbcParameter("channelID", 1))
adapter.SelectCommand = oCmd
adapter.Fill(dtReturn)
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
0
by: robindangwal | last post by:
Hi, I've this problem where I have to invoke a MySql stored procedure from my C program. I searched a lot for this. But I couldn't find any solution to this problem. Please help me how to do...
0
by: IGKogan | last post by:
3 mounth ago I serfed web to find some kind of mysql stored procedure debugger. But I found nothing. Last week at last a tool with integrated debugger was released. MySql Developer Studio 2.0...
5
by: Dennis | last post by:
Hi I'm trying to alter my stored procedure to take a parameter for the Database Name, but as usual the syntax is killing me. Thanks for any help Dennis ...
1
by: sbettadpur | last post by:
hello i want to call mysql stored procedure from php, if anybody knows please explain me clearly or any url regarding this subject
5
by: Urmi Biswas | last post by:
Hi All, Has anyone tried calling MySQL stored procedure from php scripts? I use PEAR DB module to access MySQL database. Not sure if php 4.4.0 (that we use) support calling stored procedures. ...
0
by: SLauren | last post by:
Hi, Can anyone please help me how can i debug a mysql stored procedure using toad software?? Thanks in advance, Lauren
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: tokcy | last post by:
Hi all, After a long time i am back with a new problem. Right now I am having a problem with stored procedure. I am using stored procedure with PHP/MYSQL. And evry time I am changing the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.