i like to call the stored function in c#.i need articles and some examples for this
+1
A:
http://forums.asp.net/p/988462/1278686.aspx
MySqlCommand cmd = new MySqlCommand("DeleteMessage", new MySqlConnection(GetConnectionString()));
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new MySqlParameter("param1", MessageItem.Entry_ID));
cmd.Connection.Open();
int i = cmd.ExecuteNonQuery();
cmd.Connection.Close();
Svisstack
2010-07-12 12:18:44
WHR DO U GET RETURNING VALUE
ratty
2010-07-12 12:24:59
@ratty: in `i` you have.
Svisstack
2010-07-12 12:27:57
+2
A:
It's almost identical to how you would call a SQL Server Stored Procedure:
using(MySqlConnection conn = new MySqlConnection(connString))
{
MySqlCommand command = new MySqlCommand("spSomeProcedure;", conn);
command.CommandType = System.Data.CommandType.StoredProcedure;
// Add your parameters here if you need them
command.Parameters.Add(new MySqlParameter("someParam", someParamValue));
conn.Open();
int result = (int)command.ExecuteScalar();
}
Justin Niessner
2010-07-12 12:21:50
A:
Stored functions and stored procedures are called in different ways.
Stored function is used as regular function in SQL statement. For example
SELECT id, title, my_function(price) FROM table
Stored procedures are called using CALL statement.
CALL my_procedure(1,2,'title');
I don't know C#, so probably you can use MySqlCommand class to call stored procedures, but you can't use it to call stored functions.
Naktibalda
2010-07-12 12:41:18