C# 后台调用存储过程
2021-06-17 09:04
标签:ddr tab turn command exce esc ext arch set 例一丶返回集合 例二丶执行查询,并返回由查询返回的结果集中的第一行的第一列【ExecuteScalar】 C# 后台调用存储过程 标签:ddr tab turn command exce esc ext arch set 原文地址:https://www.cnblogs.com/chenze-Index/p/10333788.html [WebMethod]
public object RegisterMethod(string type, string username, string password, string devicecode)
{
string connectString = System.Configuration.ConfigurationSettings.AppSettings["connStr"];
SqlConnection conn = new SqlConnection(connectString);
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "Proc_Register";
comm.CommandType = System.Data.CommandType.StoredProcedure;
List
public object RegisterMethod2(string type, string username, string password, string devicecode)
{
try
{
string connectString = System.Configuration.ConfigurationSettings.AppSettings["connStr"];
SqlConnection conn = new SqlConnection(connectString);
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "Proc_Register";
comm.CommandType = System.Data.CommandType.StoredProcedure;
//传值以及赋值
SqlParameter[] sps = new SqlParameter[] {
new SqlParameter("@type",type),
new SqlParameter("@username",username),
new SqlParameter("@password",password),
new SqlParameter("@devicecode",devicecode)
};
comm.Parameters.AddRange(sps);
object Result1 = comm.ExecuteScalar();
return Result1;
}
catch (Exception ex)
{
return "";
}
}