Http://www.cnblogs.com/annabook/p/3835436.html
1.
#region"Stored procedures in SQL Server process out return values"//Public void GetData ()//{ //string str = "SERVER=192.168.XXXX; user id=xxx; [Email protected]#;d atabase=xxxxx_db;min pool Size=4;max pool Size=4;packet size=3072 "; //SqlConnection conn = new SqlConnection (str); //Conn. Open (); //SqlCommand cmd = new SqlCommand (); //cmd.commandtype = CommandType.StoredProcedure; //cmd.commandtext = "sp_xxxxxx"; //cmd. Parameters.Add ("@xxxx", SqlDbType.Int); // //Note that the output parameter is set to size, otherwise the size defaults to 0,//cmd. Parameters.Add ("@FLAG", SqlDbType.Int); // //the type of the set parameter is the output parameter, which is input by default ,//cmd. parameters["@FLAG"]. Direction = ParameterDirection.Output; // //Assigning a value to a parameter//cmd. parameters["@xxxx"]. Value = 81; //cmd. Connection = conn; // //Execution//cmd. ExecuteNonQuery (); // //To get the value of the output parameter, assign the value to name, notice that the object type is given here, and the corresponding type rotation//string name = cmd. parameters["@FLAG"]. Value.tostring (); //Response.Write (name); //} #endregion
2.
#region "MySQL stored procedure processing out return value"/* public void GetData () {string str = "Server=192.168.xxx;da tabase=xxxxx_db; Port=xxxx;user id=xxxxx;password= providername=mysql.data.mysqlclient "; Mysqlconnection conn = new mysqlconnection (str); Conn. Open (); Mysqlcommand cmd = new Mysqlcommand (); Cmd.commandtype = CommandType.StoredProcedure; Cmd.commandtext = "Sp_xxxxx"; Cmd. Parameters.Add ("_xxxx", Mysqldbtype.int32, 11); Note that the output parameter is set to size, otherwise the size defaults to 0, cmd. Parameters.Add ("_flag", Mysqldbtype.int32, 11); The type of the set parameter is the output parameter, which by default is input, cmd. parameters["_flag"]. Direction = ParameterDirection.Output; Assign a value of CMD to the parameter. parameters["_xxxxx"]. Value = 81; Cmd. Connection = conn; Executes CMD. ExecuteNonQuery (); To get the value of the output parameter, assign the value to name, note that here is the type of object, to do the corresponding type rotation string name = cmd. parameters["_flag"]. Value.tostring (); Response.Write (name); }*/#endregion
SQL Server and MySQL stored procedures out return value Processing C # code