Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

asp.net : paging on a gridview with OleDbDataReader as datasource

  • 15-01-2008 02:39PM
    #1
    Registered Users, Registered Users 2 Posts: 872 ✭✭✭


    Hi,

    Im passing up data from an access db as a OleDbDataReader object. I then bind this to a gridview. When i try and enable paging i get an error The data source does not support server-side data paging.

    Is there an easy workaround for this ? Thanks
    public static OleDbDataReader connectDb(string sql)
        {
            //create the database connection
            OleDbConnection aConnection = new OleDbConnection(dbConnection);
    
            //create the command object and store the sql query
            OleDbCommand aCommand = new OleDbCommand(sql, aConnection);
    
            aConnection.Open();
    
            OleDbDataReader aReader = aCommand.ExecuteReader();
    
            return aReader;
            
            aConnection.Close();
        }
    


Comments

  • Registered Users, Registered Users 2 Posts: 610 ✭✭✭nialo


    Your using a datareader instead of a dataset. switch to a dataset and it should work fine.


  • Registered Users, Registered Users 2 Posts: 872 ✭✭✭grahamor


    I cant seem to convert my OleDbDataReader to a dataset, do you know how i can do this?

    Would i be better connecting to the access db some other way ?

    Thanks for the help


  • Registered Users, Registered Users 2 Posts: 610 ✭✭✭nialo


    Code adapted...
    grahamor wrote: »
    Hi,
    public static DataSet connectDb(string sql)
        {
            //create the database connection
            OleDbConnection aConnection = new OleDbConnection(dbConnection);
    
            //create the command object and store the sql query
            OleDbCommand aCommand = new OleDbCommand(sql, aConnection);
    
            aConnection.Open();
    
                                             Dataset myDataset = new Dataset() 
             OleDbDataAdapter myAdapter = new OleDbDataAdapter(aCommand) 
             myAdapter.Fill(myDataset) 
     
             return myDataset; 
    
        }
    


  • Registered Users, Registered Users 2 Posts: 872 ✭✭✭grahamor


    Thanks for all your help Nialo


Advertisement