Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the parameter transfer methods in linked databases in C # and asp.net

Shulou Source: shulou.com Published: 2022-06-03 14:02:44 11月14日 Update

This article mainly introduces the method of parameter transfer in the link database in C # and asp.net, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

Example analysis

# region Parameter transfer method first / / Parameter setting method (first) / / SqlParameter sp = new SqlParameter ("@ Name", str_Name); / / SqlParameter sp2 = new SqlParameter ("@ Pwd", str_Pwd); / / cmd.Parameters.Add (sp); / / cmd.Parameters.Add (sp2) # endregion// is simple and generally uses the first # region parameter passing the second method (is the first omit to pass variables) cmd.Parameters.Add (new SqlParameter ("@ Name", str_Name)); cmd.Parameters.Add (new SqlParameter ("@ Pwd", str_Pwd)) # third method of endregion#region parameter passing (array passing) / / SqlParameter [] sp = new SqlParameter [] {new SqlParameter ("@ Name", str_Name), new SqlParameter ("@ Pwd", str_Pwd)}; / / cmd.Parameters.AddRange (sp); # fourth method of endregion#region parameter passing (AddWithValue) / / cmd.Parameters.AddWithValue ("@ Name", str_Name); / / cmd.Parameters.AddWithValue ("@ Pwd", str_Pwd) # endregion// large projects generally use the fifth method of # region parameter passing (similar to the first, adding database parameter types) / / SqlParameter sps = new SqlParameter ("@ Name", SqlDbType.NVarChar); / / SqlParameter sps2 = new SqlParameter ("@ Pwd", SqlDbType.NVarChar); / / sps.Value = str_Name; / / sps2.Value = str_Pwd; / / cmd.Parameters.Add (sps) / / cmd.Parameters.Add (sps2); # endregion Thank you for reading this article carefully. I hope the article "what are the parameter transfer methods in the link database in C# and asp.net" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Parameters methods articles data databases links clips values interests variables at the same time arrays more friends knowledge examples types ribbons industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Xiaomi Shulou Tech Info Docker