用这个
public static SqlConnection SQLConn()
{
string ConnStr = ConfigurationManager.ConnectionStrings["gngsdb_heatingConn"].ConnectionString;
ConnStr = ConfigurationManager.ConnectionStrings["AGWebHeating"].ConnectionString;
ConnStr = ConfigurationManager.ConnectionStrings["AGHeating"].ConnectionString;
//ConnStr = ConfigurationManager.ConnectionStrings["AGHeatinga"].ConnectionString;
try
{
return new SqlConnection(ConnStr);
}
catch
{
return null;
}
}
//获取查询语句的结果 DataSet
public static DataSet QuerySQL(string SQLTxt,SqlConnection Conn)
{
try
{
DataSet DS = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(SQLTxt, Conn);
da.Fill(DS);
Conn.Close();
return DS;
}
catch
{
return null;
}
}
string SQLStr = 'select Name,Sex,Card,RoomID,Type,Mobile,Money,IsAddBed from Guest where Users'
DataSet DS = QuerySQL(SQLStr,SQLConn());
Label1.Text = DS.Tables[0].Rows[0]["Name"].ToString();