You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB
C#

10 months ago
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace DSWeb.EntityDA
{
public class DB
{
public DB()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection SqlConn
{
get { return new SqlConnection("server=(local);database=shippingweb;uid=sa;pwd=;"); }
}
public static DataTable GetTable(string sql)
{
using (SqlConnection conn = SqlConn)
{
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
}
public static int Execute(string sql)
{
using (SqlConnection conn = SqlConn)
{
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
return cmd.ExecuteNonQuery();
}
}
}
}