Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Calling stored procedure from .NET (1 reply)

$
0
0
Hi all,

i hope someone is able to help me with this, because its kinda weird...

What i've got:
A stored procedure:

----
DELIMITER $$
CREATE
PROCEDURE `sp_test`.`testsp`(OUT var_out int)
BEGIN
select 20 into var_out;
END$$
DELIMITER ;
----

an account with 'can do everything' access to the server

and this VB.Net Code:

----
Dim tSQLCmd As New MySqlCommand("testsp")
tSQLCmd.CommandType = CommandType.StoredProcedure
tSQLCmd.Connection = _mysqlConnection

tSQLCmd.Parameters.Add("var_out", MySqlDbType.Int32)
tSQLCmd.Parameters("var_out").Direction = ParameterDirection.Output
tSQLCmd.ExecuteNonQuery()
----

Note: i've tried "var_out", "?var_out" and as seen above "@var_out".
The SQL connection is up and running
(Connection string is: "server=127.0.0.1;uid=root;pwd=root;database=sp_test")

However, everytime when executing "tSQLCmd.ExecuteNonQuery()"
i keep getting exceptions like this:

"Parameter '@2170388462var_out' must be defined."
Note: This number (2170388462) keeps changing everytime.

It works when using StoredProcs without OUT vars, but as soon as i add any OUT var's
it throws exceptions :/

Any idea?

Oh btw:
MySQL Server 5.1.41-community
.NET Connector 5.2.0.0

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>