摘要:
static class SqlHelper{ private static string strConn = ConfigurationManager.ConnectionStrings["连接字符串的名字"].ConnectionString; public static int ExecuteNonQuery(string sql,params SqlParameter[] parameters) { using(SqlConnection conn = new SqlConnection(strConn)) { con... 阅读全文
摘要:
刚开始学数据库连接。。。一步一步来。。。using (SqlConnection conn = new SqlConnection("Data Source = .; Initial Catalog = 数据库名; User Id = sa; Password = 123456;")) //连接数据库{ conn.open(); //打开数据库 using(SqlCommand cmd = conn.CreateCommand()) //创建数据库命令对象 { cmd.CommandText = "select * from MyLo... 阅读全文