日期:2014-05-20 浏览次数:20903 次
<connectionStrings>
<add name="Conn" connectionString="Data Source=192.168.1.109;Initial Catalog=GuoHong;Persist Security Info=True;User ID=sa password=123"/>
</connectionStrings>
public class DBHelper
{
public static string Conn = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
public static DataTable ExecuteDataTable(string sql,params SqlParameter[] para)
{
using(SqlConnection conn=new SqlConnection(Conn))
{
conn.Open();
using(SqlCommand cmd=conn.CreateCommand())
{
cmd.CommandText = sql;
cmd.Parameters.AddRange(para);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds.Tables[0];
}
}
}
}
protected void Page_Load(object sender, EventArgs e)