日期:2014-05-17 浏览次数:20494 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
///ClassConnection 的摘要说明
/// </summary>
public class ClassConnection
{
private static string strConnection="";//连接字符串
static ClassConnection()
{
strConnection = "Data Source=. ;Database=HospitalManage;Integrated Security=True";
}
/// <summary>
/// 按要求查询得到表,并返回DataTable
/// </summary>
/// <param name="strSelect"></param>
/// <returns></returns>
public static DataTable selectTable(string strSelect)
{
if (strConnection == "")
{
return null;
}
SqlConnection con = new SqlConnection(strConnection);
con.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(strSelect, con);
DataTable dt = new DataTable();
try
{
dbAdapter.Fill(dt);
con.Close();
return dt;
}
catch
{
return null;
}
}
}