SqlServer和MySQL中存储过程out返回值处理C#代码
生活随笔
收集整理的這篇文章主要介紹了
SqlServer和MySQL中存储过程out返回值处理C#代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.SqlServer中out處理 C#代碼
#region"SqlServer中存儲過程處理out返回值"//public void getdata()//{// string str = " server=192.168.xxxx ;user id=xxx;password=xxxxx@#;database=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);// //注意輸出參數(shù)要設(shè)置大小,否則size默認(rèn)為0,// cmd.Parameters.Add("@FLAG", SqlDbType.Int);// //設(shè)置參數(shù)的類型為輸出參數(shù),默認(rèn)情況下是輸入,// cmd.Parameters["@FLAG"].Direction = ParameterDirection.Output;// //為參數(shù)賦值// cmd.Parameters["@xxxx"].Value = 81;// cmd.Connection = conn;// //執(zhí)行// cmd.ExecuteNonQuery();// //得到輸出參數(shù)的值,把賦值給name,注意,這里得到的是object類型的,要進(jìn)行相應(yīng)的類型輪換// string name = cmd.Parameters["@FLAG"].Value.ToString();// Response.Write(name);//}#endregion
2.mysql 中 out C#代碼
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/annabook/p/3835436.html
總結(jié)
以上是生活随笔為你收集整理的SqlServer和MySQL中存储过程out返回值处理C#代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sharepoint在itemUpdat
- 下一篇: SQL Server创建索引(转)