How to fill a OleDbDataAdapter with more than 12 records from Access DB

Pat Hanks 141 Reputation points
2023-09-14T22:16:54.7766667+00:00

I have an app I am building that uses Access as the DB. While I am developing it, I have the DB located on a network share. I just ran into a limitation during the OleDbDataAdapter.Fill method where it is only returning 12 records. If I move the DB to the local drive, it will return the proper amount of rows. My connect string is really simple "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\filepath....\TFS_db.mdb"

Here is the section that is retrieving the records. (sqlText has the query string & RecipeTableName is the name of the table.)

using (var connection = new OleDbConnection(libRegistry.ConnectString))
using (OleDbDataAdapter dataadapter = new OleDbDataAdapter(sqlText, connection))
{
connection.Open();
ds.Tables.Add(RecipeTableName);
int rowsFilled = dataadapter.Fill(ds, RecipeTableName);
}

Is this a limitation in the OLEDB or Access? If so is there a way to work around it? I haven't been able to find anything from my searches related to a limitation.

Thanks for your help!

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,386 Reputation points
    2023-09-15T01:01:53.53+00:00

    There is no limitation for a regular SELECT column names FROM SomeTable.

    Unless there is a really solid reason for using .mdb move to .accdb and try with similar code to the following. See if that works or not before using a DataAdatper. Also double check your connection string is pointing to the correct database.

    public static DataTable GetAll()
    {
        DataTable table = new DataTable();
        using OleDbConnection cn = new() { ConnectionString = "TODO"};
        using OleDbCommand cmd = new() { Connection = cn };
        cmd.CommandText = "SELECT Id, FirstName, LastName FROM Person";
        cn.Open();
        table.Load(cmd.ExecuteReader());
        return table;
    }
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful