using System; using System.Collections.Generic; using System.Linq; using System.Text; //引用sql using System.Data.SqlClient; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //连接字符串 string sql = "server=.;database=Data0216;user=sa;pwd=123;"; //数据库连接类 SqlConnection conn = new SqlConnection(sql); //数据库操作类 SqlCommand cmd = conn.CreateCommand(); //cmd.CommandText = "insert into Users values('zhaoliu','1234','赵六',1,'2004-4-4','N001');"; //cmd.CommandText = "update Users set NickName = '小六子' where username = 'zhaoliu'"; //编写TSQL语句 cmd.CommandText = "delete from Users where username='zhaoliu'"; //打开数据库连接 conn.Open(); //执行操作 cmd.ExecuteNonQuery(); //关闭数据库连接 conn.Close(); Console.ReadLine(); } } }