basic MS Access Question.. get a data into a dataset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aussie Rules

    basic MS Access Question.. get a data into a dataset

    Hi,

    Just learning how to use VB.net and Access databases. I am use to working
    against a SQL server.

    I have a Oledb connection to an access database. I have created a query in
    the access database that I want to create a dataset in my vb app using the
    query data.

    I am able to get the query results into a reader, but I need it in a
    dataset, as a thirdpart grid i am using requires a dataset (as it has a
    iBindinglist)

    my code for the datareader is :

    dim dbConnection As New OleDbConnection
    dbConnection.Co nnectionString = ("Provider=Micr osoft.ACE.OLEDB .12.0;Data
    Sou... ETC..)
    dbConnection.Op en()
    dim command As New OleDbCommand("s elect * from projectcosts", dbConnection)

    dim reader As OleDbDataReader = command.Execute Reader()


    what do i have to do to get my result into a dataset ?

    Thanks


  • Jack Jackson

    #2
    Re: basic MS Access Question.. get a data into a dataset

    On Sat, 16 Feb 2008 06:59:52 -0000, "Aussie Rules" <aussie@nospam. com>
    wrote:
    >Hi,
    >
    >Just learning how to use VB.net and Access databases. I am use to working
    >against a SQL server.
    >
    >I have a Oledb connection to an access database. I have created a query in
    >the access database that I want to create a dataset in my vb app using the
    >query data.
    >
    >I am able to get the query results into a reader, but I need it in a
    >dataset, as a thirdpart grid i am using requires a dataset (as it has a
    >iBindinglist )
    >
    >my code for the datareader is :
    >
    >dim dbConnection As New OleDbConnection
    >dbConnection.C onnectionString = ("Provider=Micr osoft.ACE.OLEDB .12.0;Data
    >Sou... ETC..)
    >dbConnection.O pen()
    >dim command As New OleDbCommand("s elect * from projectcosts", dbConnection)
    >
    >dim reader As OleDbDataReader = command.Execute Reader()
    >
    >
    >what do i have to do to get my result into a dataset ?
    Look at DataSet.Load()

    Comment

    • Steve Gerrard

      #3
      Re: basic MS Access Question.. get a data into a dataset

      Aussie Rules wrote:
      Hi,
      >
      Just learning how to use VB.net and Access databases. I am use to
      working against a SQL server.
      >
      I have a Oledb connection to an access database. I have created a
      query in the access database that I want to create a dataset in my vb
      app using the query data.
      >
      dim dbConnection As New OleDbConnection
      dbConnection.Co nnectionString =
      ("Provider=Micr osoft.ACE.OLEDB .12.0;Data Sou... ETC..)
      dbConnection.Op en()
      dim command As New OleDbCommand("s elect * from projectcosts",
      dbConnection)
      I would ditch the reader, and use an adapter, something like this:

      Dim ds As New DataSet
      Dim da As New OleDbDataAdapte r(command)
      da.Fill(ds)


      Comment

      Working...