标签:set ring cal cut init sharp data comm 入门
//1.0连接字符串 string conStr = "Data Source=.;Initial Catalog=test;User ID=sa;Password=‘qwertyu‘"; //2.0返回第行第一列结果 using (SqlConnection conn = new SqlConnection(conStr)) { string sqlStr = @"select count(1) from sys_users where deleteflag =0"; conn.Open(); SqlCommand command = new SqlCommand(sqlStr, conn); int result = Convert.ToInt32(command.ExecuteScalar()); } //3.0返回第行第一列结果 using (SqlConnection conn = new SqlConnection(conStr)) { string sqlStr = @"insert into sys_users (ID,Name,Age) values(100,‘12334efdgdfg‘,13)"; //string sqlStr = @"insert into sys_users values(100,‘12334efdgdfg‘,13,0)"; //update Sys_Users set Name=‘pppppppppp‘ where ID=1 conn.Open(); SqlCommand command = new SqlCommand(sqlStr, conn); int result = Convert.ToInt32(command.ExecuteNonQuery()); } //4.0返回结果集 SqlDataAdapter da = new SqlDataAdapter("select name from Sys_Users where DeleteFlag=0;select age from Sys_Users where DeleteFlag=0", conStr); DataSet ds = new DataSet(); da.Fill(ds);
标签:set ring cal cut init sharp data comm 入门
原文地址:https://www.cnblogs.com/junhuang/p/9410780.html