Link to home
Start Free TrialLog in
Avatar of Poppygb
PoppygbFlag for United States of America

asked on

Access query in vb.net 2010

1. I am new to vb.net. My question is: can you run querys from an access database 2010 from vb.net , if so can someone explain to my how?

2. Can you do the same with macros? if so how.

3. I will need to do the following with-in vb.net:
Add a record
update record
delete record

I will need some examples. Please help.
Avatar of jamesrh
jamesrh
Flag of United States of America image

There are 2 primary ways that you can interact with an Access db from .NET.  1) Use ADO.NET to run SQL statements against the db as a backend. 2)  Use Access automation to run Access as an application an have the Access application do the queries, etc.

Option 1 is generally preferred  when possible.  However for doing very Access specific things like running Access macros, interacting directly with Access forms and reports you need option 2.

For adding, updating, and deleting records option 1 is would usually be the way to go.

There are many specific examples of interacting with databases of all sorts using VB.NET and ADO.NET.  If you could give a little more info on what you are trying to do it would be helpful.  For instance, web or windows app?  Do you need to see/manipulate the data you are updating/changing?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Poppygb

ASKER

I wish I could get some code examples or a good book that goes more into detal.
Other wise GOOD WORK
Here's a link on automating Access from .NET:

http://support.microsoft.com/kb/317113

You need a Reference to the Access library, and then you do this:

Dim oAccess As Access.Application
oAccess = New Access.ApplicationClass
oAccess.OpenCurrentDatabase("Path to your db")

'/ now use the oAccess object:
oAccess.Docmd.RunMacro "YourMacroName"

'/ be sure to close the object:
oAccess.Close
oAccess = Nothing