1.0 connection Strings String constr = "Data source=.;i Nitial catalog=test; User Id=sa; password= ' Qwertyu ' "; 2.0 returns the first column of the row results 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 returns the first column of the row results using (SqlConnection conn = new SqlConnection (constr)) { String sqlstr = @ "INSERT into sys_users (id,name,age) VALUES (12334EFDGDFG ', 13)"; String sqlstr = @ "INSERT into sys_users values (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 Returns the result set 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);
Getting Started with ADO