日期:2014-05-16 浏览次数:20440 次
DataSet myds;
myds = Query("SELECT * FROM Test");
//
//将myds显示到页面…………
//
/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param >查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
ds.Clear();
connection.Open();
SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.SqlClient.SqlException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}