62,025
社区成员
发帖
与我相关
我的任务
分享
public static DataTable ReturnDataTable(string cmdtext)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "数据库连接字符串";
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand(cmdtext, cn);
cmd.CommandType = CommandType.Text; ;
SqlDataReader dr = null;
using (dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
dt.Load(dr);
}
return dt;
}