Microsoft Access: Using "fill" method on a DataAdapter with MS Access DB

  • mknapp / 102 / Fri, 27 Mar 2009 12:43:00 GMT / Comments (2)
  • Hi -

    I'm creating an aspx page that summarizes the number of entries in a database based upon unique column values.

    I have two queries being executed. The first selects all records from a MS Access database table. The second selects DISTINCT records from the same MS Access table.

    The code works fine for both queries when querying a SQL Server database using the "System.Data.SqlClient" Namespace, bit when using ODBC or OLEDB I get the following error when "fill"ing my DataSet with the data selected using a SQL DISTINCT query.....

    "System.Data.Odbc.OdbcException: ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1"

    Code looks like this:

    Dim Connect As New OdbcConnection
    Dim QueryString2 as String
    Dim Adapter As OdbcDataAdapter = New OdbcDataAdapter
    Dim dwppDS As DataSet = New DataSet
    Connect.ConnectionString = "DSN=DWPP_database"
    QueryString2 = "SELECT DISTINCT System_prefix FROM SOURCETABLE"
    Dim dwppCmd2 As OdbcCommand = New OdbcCommand (QueryString2, Connect)
    Adapter.SelectCommand = dwppCmd2
    Adapter.SelectCommand.Connection.Open
    ---> Adapter.Fill(dwppDS, "DISTINCT_SOURCE") <----error here
    Adapter.SelectCommand.Connection.Close

    Any help would be much appreciated....

    Thanks,

    M. Knapp

  • Keywords:

    fill, method, dataadapter, ms, access, db, microsoft

  • http://www.edevs.com/ms-access-database/289/«« Last Thread - Next Thread »»
    1. In your case, it looks like the "System_prefix" column is not a column from your SOURCETABLE table. Check your database schema. Your code is fine otherwise.

      Doug Rothaus
      douglasr...microsoft.com
      This posting is provided AS IS, with no warranty.

      dougr | Mon, 31 Dec 2007 16:25:00 GMT |

    2. Thanks Doug. That's exactly what the problem was.

      -M. Knapp

      mknapp | Mon, 31 Dec 2007 16:26:00 GMT |

  • Microsoft Access Questions

    • On Focus on Edit Textbox

      When I want to edit/update a row in a datagrid, is there a way to place the mouse focus on that text...

      By donetbeginner

    • Using "SELECT INTO" command in a multi-lev...

      Hi all!I've got a quite big problem!We get connected to a SYBASE DataBase, and we usually use stored...

      By lonifasiko

    • Using *_be.mdb Files

      I have a MS Access database where the Datatables are stored in a file named *_be.mdb (astrisk in pla...

      By war40k

    • sp_trace_getdata

      This is more SQL Server than ADO, but this seemed the closest discussion group to what I need.The sp...

      By petedavis

    • call insert method on objectdatasource

      Is there an easy way to call the insert method of a objectdatasource. I see the insert method, and ...

      By switter65, 4 Comments

    • Using "HyperLinkField"

      Using Visual Studio 2005. I am attempting to use the following (as an example, see actual code in li...

      By smokinjoe, 5 Comments

    • Using "New" for "Object reference not ...

      Hi,I'm trying to build a sql insert statement by reading through each textbox the footer of a DataGr...

      By capella07, 8 Comments

    • Using "Like" in sql syntax

      Hi,When I use "Select DISTINCT * FROM USERS Where UserName Like '*70*' " directly as a query in acss...

      By dan333, 1 Comments

    • Sourcing powerful datagrid

      Hi all,I am sourcing powerful datagrid components (for web page and windows form) that contains at l...

      By bryan123, 3 Comments