public class StudentService { //从配置文件中读取数据库连接字符串 private readonly static string connString = ConfigurationManager.ConnectionStrings["accpConnectionString"].ToString(); private readonly static string dboOwner = ConfigurationManager.ConnectionStrings["DataBaseOwner"].ToString(); AdoNetModels.Student model = new Student();
#region 删除数据1 public int DeleteStudent(int stuID) { int result = 0; // 数据库连接 Connection 对象 SqlConnection connection = new SqlConnection(connString); // 构建删除的sql语句 string sql = string.Format("Delete From Student Where stuID={0}", stuID); // 定义command对象 SqlCommand command = new SqlCommand(sql, connection);