新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
///
///DBOperate 的摘要说明
///
public class DBOperate
{
private static SqlConnection con = null;
private static SqlCommand cmd = null;
private static SqlDataAdapter da = null;
// private static SqlDataReader dr = null;
public static SqlConnection createCon()
{
string constr = ConfigurationManager.AppSettings["server"];
//string constr = ConfigurationManager.ConnectionStrings["connection"].ToString();
con = new SqlConnection(constr);
return con;
}
public static int execSQL(string sql)
{
int rows;
try
{
con = createCon();
if (con.State != ConnectionState.Open)
con.Open();
cmd = new SqlCommand(sql, con);
rows= cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
finally
{
if (con.State == ConnectionState.Open)
con.Close();
}
return rows;
}
public static DataSet getDataSet(string sql, string table)
{
try
{
con = createCon();
da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds, table);
return ds;
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
}
public static SqlDataReader getReader(string sql)
{
try
{
con = createCon();
if (con.State != ConnectionState.Open)
con.Open();
cmd = new SqlCommand(sql, con);
return cmd.ExecuteReader();
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
}
}
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。