哥们你试一下就知道了自己缠个库吧<% @ Page Language="VB" %>
<% @ Import Namespace="System.Data" %>
<% @ Import Namespace="System.Data.OleDb" %>
<html>
<head>
<title>第二十三例 数据库的简单查询实例</title>
<link rel="stylesheet" href="webclass.css" type="text/css">
<Script Language="VB" Runat="Server"> Dim public myConnstring as string = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("dbook.mdb")
Dim MyConnection as OleDbConnection
'定义连接的字符串为公共变量,利于多次访问 public Sub Page_Load(sender As Object,e As EventArgs)
Dim selstr as string ="Select * from dbook Order by ID"
try
MyConnection = new OleDbConnection(myConnstring)
'设定联结
Dim MyCommand as OleDbCommand = new OleDbCommand(selstr,MyConnection)
MyConnection.Open()
'打开连接
                        dim shtI as Short
Dim MyDataReader as OleDbDataReader = MyCommand.ExecuteReader()
DataGrid1.DataSource=myDataReader
DataGrid1.DataBind()
'数据的读取
Do While MyDataReader.Read()
For shtI=0 To MyDataReader.FieldCount-1
Response.Write(MyDataReader.GetValue(shtI) & " / ")
Next
Response.Write("<br>")
Loop
MyDataReader.Close()
MyConnection.Close()
catch ee As Exception
finally
End try
End Sub
</script><ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5"/><body>
<center>
 <table border=0 cellpadding=3 cellspacing=1 height=8 width="560" class="tx105pt" bgcolor="#7D007D">
        <center>
        </center>
        <tr> 
          <center>
            <td height=19 width=168><font color="#ffffff">&nbsp;<b>作者信息</b></font></td>
          </center>
          <td height=19 width=436> 
            <p align="left"><font color="#ffff00">&nbsp;<font color="#FFFFFF"><b>留言内容:</b></font></font></p>
          </td>
        </tr>
      </table>
  <table width="560" border="0" cellspacing="0" cellpadding="0" bgcolor="#7D007D">
    <tr> 
      <td> 
        <table border=0 cellpadding=3 cellspacing=1 height=8 width="560" class="tx9pt">
          <tbody> 
          <tr> 
            <td bgcolor=#FDF9FD height=8 rowspan=3 valign=top width=150> <br>
<table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">头像:</font></td>
                  <td width="110"><img src="pic/Image57.gif"></td>
                </tr>
              </table>
              <table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">大名:</font></td>
                  <td width="110">阿莱 [先生]</td>
                </tr>
              </table>
              
              <table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">OICQ:</font></td>
                  <td width="110"></td>
                </tr>
              </table>
              <table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">邮件:</font></td>
                  <td width="110"><img border=0 src="images/mail.gif" width="15" height="15">&nbsp;<a href="mailto:[email protected]">邮件</a></td>
                </tr>
              </table>
              <table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">主页:</font></td>
                  <td width="110"><img border=0 src="images/home.gif" width="15" height="15">&nbsp;<a href="http://9820.9126.com" target="_blank">主页</a></td>
                </tr>
              </table>
              <table width="150" border="0" class="tx9pt" cellspacing="0" cellpadding="1">
                <tr> 
                  <td width="40"><font color="#660066">IP:</font></td>
                  <td width="110">218.104.226.234</td>
                </tr>
              </table>
            </td>
            <td bgcolor=#f7f7f7 height=1 width=410><img src="images/text.gif" width="18" height="18"> 
              主题:羊年快乐!!! 
          <tr> 
            <td bgcolor=#ffffff height=90 width=410> 
              <table border=0 cellpadding=3 cellspacing=0 height="100%" width="100%" class="tx9pt">
                <tbody> 
                <tr> 
                  <td valign=top width="100%" height="94">是这样的:<br><br>可能是我小时候老爱吃甜食,搞得我现在牙坏得差不多了啊..<br><br>有一两个较严重,其它都蛀牙了~可我今年20岁呀..<br><br>这几天有一颗坏了一半痛要命,我想补牙,在原有的基础修复并套上一颗新牙,<br><br>请问。要怎么收费呀,。<br><br>请与我mail:[email protected]&nbsp;&nbsp;好吗?<br><br><br>羊年happey~ </td>
                </tr>
                <tr>
                  <td valign=top width="100%"><font color="#cc0000">
                    
                    </font>                    
                  </td>
                </tr>
                <tr> 
                  <td valign=top width="100%"> 
                    <div align="right">[发表于:2003-1-26 21:39:22 ]</div>
                  </td>
                </tr>
                </tbody> 
              </table>
          <tr> 
            <td bgcolor=#f7f7f7 height=10 width=410>&nbsp; <img border=0 src="images/mail.gif" width="15" height="15">&nbsp;<a href="mailto:[email protected]">邮件</a> 
              <img border=0 src="images/home.gif" width="16" height="16">&nbsp;<a href="http://9820.9126.com" target="_blank">主页</a> 
              <img alt='阿莱的IP:218.104.226.234' border=0 src="images/ip.gif" width="13" height="15">&nbsp;IP</td>
          </tr>
          </tbody> 
        </table>
      </td>
    </tr>
  </table>
</center>
</body>
</head>
</html>

解决方案 »

  1.   

    try
    <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5"/>
    改成
    <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" OnPageIndexChanged="DataGrid1_Updt"></asp:DataGrid>
    or
    <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" OnPageIndexChanged="DataGrid1_Updt" />
    还要加入分页代码:
    public void DataGrid1_Updt(object sender,DataGridPageChangedEventArgs e)
    {
    this.DataGrid1.CurrentPageIndex = e.NewPageIndex ;
    Binding();//自己绑定表格数据
    }
      

  2.   

    DLL文件损坏,建议改成代码前置,将ASPX页面导入代码一行删掉,我也有一样的问题,代码前置无问题
      

  3.   

    分页不显示多半是因为没有数据绑定的原因
     huan_jinwu(金屋藏娇,得抱源码归) 是对的,不需要"完整的代码"
    如果你没有自己的绑定函数,就把Binding();改成this.DataGrid1.DateBind();就行了
      

  4.   

    DataReader对象绑定Datagrid 不能进行分页操作!!!
    还用是DataSet对象的DefaultView来与DataGrid对象绑定