Running access query in Vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • farah123
    New Member
    • Aug 2008
    • 1

    Running access query in Vb.net

    Hello,
    I have an access database and have a simple query in which i have 1 parameter.
    I want to run this query in vb.net and display the results in a datagrid or anything but in vb.net.
    I'm able to run the query but wht should i do to display the results of the query.
    the code i m using now is:

    Dim accApp As Object
    accApp = GetObject("c:\m ydb.mdb")

    'this will run the query in the database
    accApp.docmd.Op enQuery("myQuer y")
    accApp.Run("myQ uery")
  • janders468
    Recognized Expert New Member
    • Mar 2008
    • 112

    #2
    Right now you are attempting to automate Access, which doesn't get you where you want to go because you're trying to put the application logic in vb.net. In other words what you want access to is not the Access objects, but the Data objects. To do this you will need to read up on ADO.net, the data connection API provided by the .net framework. In your case you will want to use OleDb. This gives you the ability to pull data from a table (or query) and use it in various ways, such as place it in a Dataset which can be used as the DataBinding for a Datagrid or other objects. This is actually quite a large topic and I think that it would probably be best to read up on this component of the .Net framework. Most beginning VB.net books that I have read explain the use of Ado.net using Access as the sample data store. I would recommend either looking in one of those, or searching online for ADO.Net because that is what you will want to understand to utilize the data from your Access database.

    Comment

    Working...