Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

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

Options
  • 15-01-2008 2:39pm
    #1
    Registered Users 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 Posts: 610 ✭✭✭nialo


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


  • Registered Users 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 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 Posts: 872 ✭✭✭grahamor


    Thanks for all your help Nialo


Advertisement