c#中下面一段语言的意思,麻烦详细一些 20
publicstaticboolGetReader(Stringsqlstr,paramsSqlParameter[]param){using(SqlConnection...
public static bool GetReader(String sqlstr, params SqlParameter[] param)
{
using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
bool flag = false;
cmd.CommandText = sqlstr;
cmd.Parameters.AddRange(param);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
flag = true;
}
return flag;
}
}
}
public static object GetScalar(String sqlstr, params SqlParameter[] param)
{
using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sqlstr;
cmd.Parameters.AddRange(param);
return cmd.ExecuteScalar();
}
}
} 展开
{
using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
bool flag = false;
cmd.CommandText = sqlstr;
cmd.Parameters.AddRange(param);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
flag = true;
}
return flag;
}
}
}
public static object GetScalar(String sqlstr, params SqlParameter[] param)
{
using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sqlstr;
cmd.Parameters.AddRange(param);
return cmd.ExecuteScalar();
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询