ASCII码 ASCII码

C#中调用MySQL存储过程的方法

发布于:2022-01-14 09:45:40  栏目:技术文档

本文实例讲述了C#中调用MySQL存储过程的方法。分享给大家供大家参考。具体如下:

这段代码演示在 C# 程序中调用 MySQL 的存储过程,没有返回值,没有参数传递。`MySqlConnection myConnection;myConnection = new MySqlConnection();myConnection.ConnectionString = “database=”+database+”;server=”+ server+”;user id=”+user+”;Password=”+password;try { myConnection.Open();}catch (MySqlException MyException) { Console.WriteLine(“Connection error: MySQL code: “+ MyException.Number +” “+ MyException.Message);}try { MySqlCommand myCommand = new MySqlCommand( “call error_test_proc(1)”, myConnection ); myCommand.ExecuteNonQuery();}catch (MySqlException MyException) { Console.WriteLine(“Stored procedure error: MySQL code: “ + MyException.Number + “ “ + MyException.Message);}希望本文所述对大家的C#程序设计有所帮助。

相关推荐
阅读 +