请教在aspx网页里以datagrid显示用sqlsever2000做的数据库(名称为guestdb,内有userinfo的一个表,含字段为name,qq,content等)的信息注*:本人正用asp.net及sqlsever2000在做一个简单的留言本
Auleaf GuestBook
 Name:Q Q:TEl:    Email: HomePage: 留言>>>:  查找留言   密码:

解决方案 »

  1.   

    什么意思?
    是显示表中数据到DataGrid中吗?
    1 select 表中数据并填充到DataSet中
    2 将此DataSet做为DataGrid的数据源
    3 绑上
      

  2.   

    using System.Data.SqlClient;//名称空间声明
    public string strcon=System.Configuration.ConfigurationSettings.AppSettings["dbpath"];//建立路径///以下是绑定的代码SqlConnection thisConnection=new SqlConnection(this.strcon);
       SqlDataAdapter thisAdapter=new SqlDataAdapter("SELECT * FROM leavemassage order by addtime desc",thisConnection);
       thisConnection.Open();
       DataSet thisDS=new DataSet();
       thisAdapter.Fill(thisDS,"leavemassage");
       if(thisDS.Tables.Count>0)
       {
        this.DataGrid1.DataSource=thisDS.Tables["leavemassage"];
        this.DataGrid1.DataBind();
        
       }
       thisConnection.Close();