Hi..I am developing a project
(c#.net) called mysql querybrowser..There is problem with stored procedure. Actually user will create and run stored procedure at run time...so in project creating is being done successfully but there is problem in calling stored procedure...because i have to pass the parameters at run time and if there is no parameter then no need to pass it...so i am not getting that how to do it....Plz help me asap....thanks...
I am providing the code here so you can get a little bit idea of it...
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connStr)) {
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "CALL MyProcedure(@MyParam1, @MyParam2);";
cmd.Parameters.AddWithValue("@MyParam1", 123);
cmd.Parameters.AddWithValue("@MyParam2", "blah");
conn.Open();
cmd.ExecuteNonQuery()
In cmd.commandText line how to add these myparam....because stored procedure is created run time....and also tell me the code in the case not providing any parameter..
(c#.net) called mysql querybrowser..There is problem with stored procedure. Actually user will create and run stored procedure at run time...so in project creating is being done successfully but there is problem in calling stored procedure...because i have to pass the parameters at run time and if there is no parameter then no need to pass it...so i am not getting that how to do it....Plz help me asap....thanks...
I am providing the code here so you can get a little bit idea of it...
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connStr)) {
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "CALL MyProcedure(@MyParam1, @MyParam2);";
cmd.Parameters.AddWithValue("@MyParam1", 123);
cmd.Parameters.AddWithValue("@MyParam2", "blah");
conn.Open();
cmd.ExecuteNonQuery()
In cmd.commandText line how to add these myparam....because stored procedure is created run time....and also tell me the code in the case not providing any parameter..