You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace 调度窗口
|
|
{
|
|
class Dao
|
|
{
|
|
SqlConnection sc;
|
|
//连接数据库
|
|
public SqlConnection Connect()
|
|
{
|
|
string str = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;";
|
|
sc = new SqlConnection(str);
|
|
sc.Open();
|
|
return sc; //数据库连接的对象
|
|
}
|
|
|
|
public SqlCommand command(string sql)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(sql, Connect());
|
|
return cmd;
|
|
}
|
|
public int Execute(string sql) //更新操作
|
|
{
|
|
return command(sql).ExecuteNonQuery();
|
|
}
|
|
public SqlDataReader read(string sql) //读取操作
|
|
{
|
|
return command(sql).ExecuteReader();
|
|
}
|
|
public void Daoclose()
|
|
{
|
|
sc.Close();//关闭数据库连接
|
|
}
|
|
}
|
|
}
|