SQL Server and MySQL stored procedures out return value Processing C # code

Source: Internet
Author: User
Tags mysql in

1.SqlServer out of Process C # code

  #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.mysql in out C # code

 #region"Stored procedure in MySQL processing out return value"/*        public void GetData () {string str = "server=192.168.xxx;database=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);  } */

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.