Console.Write("请输入要删除的编号:"); string ucode = Console.ReadLine(); SqlConnection conn = new SqlConnection("server=.;database=Data0504;user=sa;pwd=123;"); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "delete from Users where Ucode=‘" + ucode + "‘"; conn.Open(); int count = cmd.ExecuteNonQuery(); conn.Close(); if (count > 0) { Console.WriteLine("删除成功"); } else { Console.WriteLine("删除失败!"); } Console.ReadLine(); //这里记得添加命名空间 using System.Data.SqlClient;
时间: 2024-10-29 00:36:43