标签:scalar comm use dap 三层架构 dataset return cti div
public int count(string sql) { SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;"); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); int num = (int)cmd.ExecuteScalar(); conn.Close(); return num; } public int count1(string sql) { SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;"); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); int i = cmd.ExecuteNonQuery(); conn.Close(); return i; } public DataTable count2(string sql) { SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;"); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter dr = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); dr.Fill(ds, "shopping"); DataTable dt = ds.Tables["shopping"]; return dt; }
标签:scalar comm use dap 三层架构 dataset return cti div
原文地址:https://www.cnblogs.com/mvpbest/p/13300215.html