主题:  请问下面的代码有什么问题?

林易

职务:普通成员
等级:3
金币:1.0
发贴:750
#12005/5/8 11:53:52
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    Sub Page_Load(Sender As Object, E As EventArgs)
    
        If Not Page.IsPostBack Then
    
            ' Databind the data grid on the first request only
            ' (on postback, rebind only in paging command)
    
            BindGrid()
    
        End If
    
    End Sub
    
    Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    
        DataGrid1.CurrentPageIndex = e.NewPageIndex
        BindGrid()
    
    End Sub
    
    Sub BindGrid()
    
        ' TODO: update the ConnectionString and CommandText values for your application
      Dim myConnection As OleDbConnection
      Dim myCommand As OleDbCommand
      dim dbname as string
               dbname=server.mappath("data/#%News.mdb")
               myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
    
        Dim ds As New DataSet()
        myCommand.Fill(ds)
    
        DataGrid1.DataSource = ds
        DataGrid1.DataBind()
    
    End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <h2>Data Report with Paging 
    </h2>
    <hr size="1" />
    <form runat="server">
        <asp:datagrid id="DataGrid1" runat="server" AllowPaging="true" PageSize="6" OnPageIndexChanged="DataGrid_Page" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1" width="80%">
            <HeaderStyle font-bold="True" forecolor="white" backcolor="#4A3C8C"></HeaderStyle>
            <PagerStyle horizontalalign="Right" backcolor="#C6C3C6" mode="NumericPages"></PagerStyle>
            <ItemStyle backcolor="#DEDFDE"></ItemStyle>
        </asp:datagrid>
    </form>
</body>
</html>



错误显示这个
Compiler Error Message: BC30456: 'Fill' is not a member of 'System.Data.OleDb.OleDbCommand'.

Source Error:



Line 35:
Line 36: Dim ds As New DataSet()
Line 37: myCommand.Fill(ds)
Line 38:
Line 39: DataGrid1.DataSource = ds



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#22005/5/8 12:07:29
Fill是DataAdapter的方法~



林易

职务:普通成员
等级:3
金币:1.0
发贴:750
#32005/5/8 14:27:37
谢谢,我查资料也是这样说的,我是用web matrix 自动生成了,怎么才可以解决把程序调通



林易

职务:普通成员
等级:3
金币:1.0
发贴:750
#42005/5/8 15:56:33
我通过这样的方式实现了

dim DS as new dataset
    dim DA as oledbdataadapter
    
    da=new oledbdataadapter("select * FROM shop_books",myconnection)
           da.fill(ds,"shop_books")
           DataGrid1.DataSource=ds.tables("shop_books").defaultview
           DataGrid1.DataBind()
    


谢谢,提醒