Paging Problem - Page Error - Novice Alert

ASP.NET, VB.NET, Access Db

I am working on my first Asp.NET web page.  All was going pretty good until I tried to add the paging code to the page.  Now I am getting the following Error: BC30454: Expression is not a method. - Line 76:  objPageConn As New OleDbConnection(ConfigurationSettings.AppSettings("Contacts"))

I can't find any information on this so I may as well embarass myself by posting my novice code.  Hopefully someone can point out the problem or suggest how I may improve my code in order for it to work.


<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>

<script runat="server">

    Sub Page_Load(s as object, e as eventargs)
        Dim dsContacts As DataSet
        Dim objConn As OleDbConnection
        Dim daContacts As OleDbDataAdapter
        Dim strPath As String
        dsContacts = New DataSet()
        objConn = New OleDbConnection(ConfigurationSettings.AppSettings("Contacts"))
        daContacts = New OleDbDataAdapter("SELECT FirstName As [First Name], LastName As [Last Name], Department, Division, Phone, Fax FROM contacts", objConn)
        daContacts.Fill(dsContacts, "Contacts")
        dgContacts.DataSource = dsContacts

        Dim ddlDepartmentCommand As OleDbCommand
        ddlDepartmentCommand = New OleDbCommand("SELECT Department FROM departments ORDER BY Department ASC", objConn)
        Dim dtrDepartment As OleDbDataReader
        dtrDepartment = ddlDepartmentCommand.ExecuteReader()
        ddlDepartment.DataSource = dtrDepartment
        ddlDepartment.DataTextField = "department"
        Dim defaultItemDept as New ListItem
        defaultItemDept.Text = "Select Department"
        defaultItemDept.Value = ""
        ddlDepartment.Items.Insert(0, defaultItemDept)

        Dim ddlDivisionCommand As OleDbCommand
        ddlDivisionCommand = New OleDbCommand("SELECT division FROM divisions ORDER BY division ASC", objConn)
        Dim dtrDivision As OleDbDataReader
        dtrDivision = ddlDivisionCommand.ExecuteReader()
        ddlDivision.DataSource = dtrDivision
        ddlDivision.DataTextField = "division"
        Dim defaultItemDiv as New ListItem
        defaultItemDiv.Text = "Select Division"
        defaultItemDiv.Value = ""
        ddlDivision.Items.Insert(0, defaultItemDiv)


    End Sub

    Sub BindDataGrid( strSortField As String)

        Dim objSortConn As OleDbConnection
        Dim cmdSortSelect As OleDbCommand

        objSortConn = New OleDbConnection(ConfigurationSettings.AppSettings("Contacts"))
        cmdSortSelect = New OleDbCommand("SELECT FirstName As [First Name], LastName As [Last Name], Department, Division, Phone, Fax FROM contacts ORDER BY " & strSortField, objSortConn)
        dgContacts.DataSource = cmdSortSelect.ExecuteReader()

     End Sub

     Sub dgContacts_SortCommand(S as Object, E as DataGridSortCommandEventArgs)
     End Sub

    Sub BindDataGridPaging
        Dim objPageConn As OleDbConnection
        Dim daPageContacts As OleDbDataAdapter
        Dim dsPageContacts As DataSet

        objPageConn As New OleDbConnection(ConfigurationSettings.AppSettings("Contacts"))
        daPageContacts = New OleDbDataAdapter("SELECT FirstName As [First Name], LastName As [Last Name], Department, Division, Phone, Fax FROM contacts Order by LastName ASC")
        dsPageContacts = New DataSet

        dgContacts.DataSource = dsPageContacts

     End Sub

     Sub dgContacts_PageIndexChanged(S as Object, E as DataGridPageChangedEventArgs)
        dgContacts.CurrentPageIndex = e.NewPageIndex
     End Sub


    <form runat="server">
        <asp:TextBox id="txtLastName" runat="server" columns="30"></asp:TextBox>
        <br />
        <asp:TextBox id="txtFirstName" runat="server" columns="30"></asp:TextBox>
        <br />
        <asp:DropDownList id="ddlDepartment" runat="server">
            <asp:listitem>Select Department</asp:listitem>
        <br />
        <asp:DropDownList id="ddlDivision" runat="server">
            <asp:listitem>Select Division</asp:listitem>
        <br />
        <br />
        <asp:DataGrid id="dgContacts" AllowSorting="True" OnSortCommand="dgContacts_SortCommand" AllowPaging="True" PageSize="12" OnPageIndexChanged="dgContacts_PageIndexChanged" CellPadding="5" Runat="server"></asp:DataGrid>

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeff CertainCommented:
Sub BindDataGridPaging
        Dim objPageConn As OleDbConnection
        Dim daPageContacts As OleDbDataAdapter
        Dim dsPageContacts As DataSet

        objPageConn = New OleDbConnection(ConfigurationSettings.AppSettings("Contacts"))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeff CertainCommented:
** It's that last = sign that was an "AS"
You might need to import the System.Configuration namespace as well to be able to user ConfigurationSettings.AppSettings
paintedAuthor Commented:
Thanks, Chaosian.

That got rid of the  BC30454: Expression is not a method error.  

I also noticed when I correct the As to an = that I had left the connection out of the next line.  When I added the objPageConn, I got a new error: AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID dgContacts when Allow Paging is set to true and the selected datasource does not implement ICollection....whew!

I've been reading about paging tonight since I left work and evidently, I'm really not understanding enough about paging (or ASP.NET for that matter) to really get my head around it.  Tomorrow I'm going to try "AllowCustomPaging" to see if that will work better for me.  I've no clue about the "ICollection".  

Thanks, ryerras.

 I'll try your suggestion in the morning.  I've been getting the data, before adding the paging, that is.  Maybe that will make a difference with the paging.

One other note:  With the record paging, I will not need the first sub that populates the datagrid, will I?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.