using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace Yield_Limit_Import
{
class SQLHelper
{
SqlConnection conn = new SqlConnection(“server=IP地址;database=数据库名;uid=用户名;pwd=密码”);
public void Connection()
{
conn.Open();
}
public void Close()
{
conn.Close();
}
public DataTable GetData(string sql)
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandTimeout = 300;
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
public int InsertData(string sql)
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandTimeout = 300;
int i = cmd.ExecuteNonQuery();
return i;
}
}
}