Poppygb
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wish I could get some code examples or a good book that goes more into detal.
Other wise GOOD WORK
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.OpenCurrentDatabas e("Path to your db")
'/ now use the oAccess object:
oAccess.Docmd.RunMacro "YourMacroName"
'/ be sure to close the object:
oAccess.Close
oAccess = Nothing
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.OpenCurrentDatabas
'/ now use the oAccess object:
oAccess.Docmd.RunMacro "YourMacroName"
'/ be sure to close the object:
oAccess.Close
oAccess = Nothing
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?