第二个项目 酒店管理系统
DBHlper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class DBHelper
{
//连接字符串
public static string connstr = “server=DESKTOP-4HM5BLU;uid=sa;pwd=123456;database=hotel”;
public static DataTable ExcuteTable(string sql)
{
SqlDataAdapter sda = new SqlDataAdapter(sql, connstr);
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
public static int ExecuteNonQuery(string sql)
{
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
return comm.ExecuteNonQuery();
}
}
}