Use MSAccess Active X references in VB.NET?

SPARKY

New member
Joined
Mar 10, 2006
Messages
3
Programming Experience
1-3
Hi

I am looking forward a code example from how to use MsAccess reference in VB.net (in a Webform because I want to publish my application in a web in an internet server). I mean, in Vb 6.0 I used:

Dim AccessApplication as Access.Application
Dim DB as Database
Dim Table as Recordset

Set AccessApplication = CreateObjet("Access.Application")
Set DB=AccessAplication.OpenCurrentDatabase("Nameofthedatabase.mdb")
Set Table=DB.Openrecordset("Nameofthetableinthedatabase")

Ok, what I need is to convert this code to VB.NET (2.0) if it is possible.

I already know there is another way to obtain information from an MSAccess database (using system.oledb.oledbconnection), but I need also run an MsAccess macro and I think this is the only way to manage it.

If anybody know how to do please email me to joserrarey@euskalnet.net.

Thank you in advance.

SPARKY
 
Both strong type reference and late binding is available in .Net too.
- For strong type, first Add Reference (in COM page listing) to the Access object library of choice, then create a new instance of application object.
- For late binding use CreateObject. Make sure Option Strict is Off (default setting)
Examples: "How To Use Visual Basic .NET for Binding for Office Automation Servers" http://support.microsoft.com/kb/304661/
 
I cannot make it work yet

Sorry but I did what you told me and I cannot make it work. I wrote:

Dim AccessApplication as Object
Dim Table as Access.CurrentData

AccessApplication =CreateObject("Access.Application")
AccessApplication.Opencurrentdatabase("Nameofthe database.mdb")
Table=AccessApplication.Currentdb.Openrecordset("Nameofthetableinthedatabase")

but on compiling appears the following error:
"Cannot create ActiveX component"
"An unhandled exceptionc ocurred during the execution of the current web request..." and this error points to the following line of my program:

AccessApplication =CreateObject("Access.Application")

what do I have wrong? Could you pass me an example which works to you to prove it in my application, thanks?


Thank you for all.

SPARKY
 
I guess you had this working before with ASP and VB6,
- Access installed in webserver,
- dcom all set up,
- client webbrowser security ok,
- Server.MapPath("pathandnameofthedatabase.mdb"),
- etc...
Some more help:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q257757

(they also say this is not the best webserver with database solution if you can avoid it..)
 
JohnH said:
I guess you had this working before with ASP and VB6,
- Access installed in webserver,
- dcom all set up,
- client webbrowser security ok,
- Server.MapPath("pathandnameofthedatabase.mdb"),
- etc...
Some more help:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q257757

(they also say this is not the best webserver with database solution if you can avoid it..)


Thank you very much I see it is more difficult than I thought.
 
Back
Top