高分求C#查询SQL2000属性并在gridview中分页显示
来源:百度知道 编辑:UC知道 时间:2024/04/28 07:32:35
大哥我要的是代码,button的button_click下面的代码,自己都没搞明白的就不用给我说了,谢各位了,
绑定gridview
public void bindGrid(string name)
{
DataSet ds = new DataSet();
string strSql = "SELECT Id, UserId,TrueName,Sex, Position, Specialty, Phone,IsVouch, RisDate, State FROM cxy_Expert WHERE name='"+name+"' ORDER BY RisDate DESC";
try
{
using (sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["CiXinYuanConnectionString"].ConnectionString))//设置数据库连接 把ConfigurationManager.ConnectionStrings["CiXinYuanConnectionString"].ConnectionString改成连接字符串
{
sqlCon.Open();
using (sqlCmd = new SqlCommand(strSql, sqlCon))//执行SQL语句
{
SqlDataAdapter sqlDa = new SqlDataAdapter();
ds = new DataSet();
sqlDa.SelectCommand = sqlCmd;
sqlDa.Fill(ds, "Expert");