日期:2014-05-17 浏览次数:20413 次
using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; namespace SQLHelper { public class helper { private string sql = "server=.;uid=sa;pwd=sa;database=DB_TLY"; public SqlDataReader dr(string txtsql, SqlParameter[] par) { SqlConnection conn = new SqlConnection(sql); SqlCommand comm = new SqlCommand(txtsql,conn); if (par != null) { comm.Parameters.AddRange(par); } conn.Open(); return comm.ExecuteReader(); } public int Execute(string txtsql, SqlParameter[] par) { SqlConnection conn = new SqlConnection(sql); SqlCommand comm = new SqlCommand(txtsql, conn); if (par != null) { comm.Parameters.AddRange(par); } conn.Open(); return comm.ExecuteNonQuery(); } } }