时间:2021-07-01 10:21:17 帮助过:3人阅读
2.
#region"MySQL中存储过程处理out返回值" /* 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); //注意输出参数要设置大小,否则size默认为0, cmd.Parameters.Add("_FLAG", MySqlDbType.Int32, 11); //设置参数的类型为输出参数,默认情况下是输入, cmd.Parameters["_FLAG"].Direction = ParameterDirection.Output; //为参数赋值 cmd.Parameters["_xxxxx"].Value = 81; cmd.Connection = conn; //执行 cmd.ExecuteNonQuery(); //得到输出参数的值,把赋值给name,注意,这里得到的是object类型的,要进行相应的类型轮换 string name = cmd.Parameters["_FLAG"].Value.ToString(); Response.Write(name); }*/ #endregion
SqlServer和MySQL中存储过程out返回值处理C#代码
标签: