如何在C#中调用mySQL存储函数?

rat*_*tty 1 c# mysql

我想在C#中调用存储函数.我需要文章和一些例子.

Jus*_*ner 6

它几乎与您调用SQL Server存储过程的方式相同:

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();
}
Run Code Online (Sandbox Code Playgroud)