A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

From VB .Net, how obtain ref to Access project?



 
 
Thread Tools Display Modes
  #1  
Old February 7th, 2005, 09:09 PM
Ed White
external usenet poster
 
Posts: n/a
Default From VB .Net, how obtain ref to Access project?

From VB .Net, using either DAO or ADOX (or whatever else is available), how
can I obtain a reference to a database file created in Access? For example,
I tried the following:

Dim AccessApp As New Microsoft.Office.Interop.Access.Application
AccessApp.OpenCurrentDatabase("C:\Documents and Settings\...\filename.mdb")
Dim cat As ADOX.Catalog
cat.ActiveConnection = AccessApp.CurrentProject.Connection

The last statement gives me a "Object reference not set to an instance of an
object" error.
--
Ed
  #2  
Old February 7th, 2005, 09:39 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

The immediate problem here is that you've declared the "cat" variable but
never instantiated it - you're missing a "Set cat = New ADOX.Catalog" line.

Beyond that, you're mixing automation and data access, which are really two
separate things. What is it you want to do - automate the Access
application, or just get at the data from your .NET code?

--
Brendan Reynolds (MVP)


"Ed White" .(donotspam) wrote in message
...
From VB .Net, using either DAO or ADOX (or whatever else is available),
how
can I obtain a reference to a database file created in Access? For
example,
I tried the following:

Dim AccessApp As New Microsoft.Office.Interop.Access.Application
AccessApp.OpenCurrentDatabase("C:\Documents and
Settings\...\filename.mdb")
Dim cat As ADOX.Catalog
cat.ActiveConnection = AccessApp.CurrentProject.Connection

The last statement gives me a "Object reference not set to an instance of
an
object" error.
--
Ed



  #3  
Old February 7th, 2005, 11:55 PM
Ed White
external usenet poster
 
Posts: n/a
Default

Essentially, I'm trying to do in VB .Net what is done in VBA under Access,
i.e. I'm trying to write code in VB .Net to manipulate a database using the
same/similar commands available in Access VBA. I see the commands in the VB
..Net Object Library (after adding the appropriate references), I just can't
get the commands to talk to the approrpiate .mdb file. For example, in my
prior post "How to add new table programatically" on 2/2/05 which you
responded to, you told me how to add new tables using DAO, ADOX, and DDL. I
got the DDL to work, but I couldn't figure out how to access the .mdb file in
DAO or ADOX.

"Brendan Reynolds" wrote:

The immediate problem here is that you've declared the "cat" variable but
never instantiated it - you're missing a "Set cat = New ADOX.Catalog" line.

Beyond that, you're mixing automation and data access, which are really two
separate things. What is it you want to do - automate the Access
application, or just get at the data from your .NET code?

--
Brendan Reynolds (MVP)


"Ed White" .(donotspam) wrote in message
...
From VB .Net, using either DAO or ADOX (or whatever else is available),
how
can I obtain a reference to a database file created in Access? For
example,
I tried the following:

Dim AccessApp As New Microsoft.Office.Interop.Access.Application
AccessApp.OpenCurrentDatabase("C:\Documents and
Settings\...\filename.mdb")
Dim cat As ADOX.Catalog
cat.ActiveConnection = AccessApp.CurrentProject.Connection

The last statement gives me a "Object reference not set to an instance of
an
object" error.
--
Ed




  #4  
Old February 8th, 2005, 12:22 AM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

I'm afraid I won't be able to help you with that, Ed. You could try asking
in a .NET newsgroup. I think the answer will probably be that this approach
is not practical, but who knows, I could be wrong.

--
Brendan Reynolds (MVP)


"Ed White" .(donotspam) wrote in message
...
Essentially, I'm trying to do in VB .Net what is done in VBA under Access,
i.e. I'm trying to write code in VB .Net to manipulate a database using
the
same/similar commands available in Access VBA. I see the commands in the
VB
.Net Object Library (after adding the appropriate references), I just
can't
get the commands to talk to the approrpiate .mdb file. For example, in my
prior post "How to add new table programatically" on 2/2/05 which you
responded to, you told me how to add new tables using DAO, ADOX, and DDL.
I
got the DDL to work, but I couldn't figure out how to access the .mdb file
in
DAO or ADOX.

"Brendan Reynolds" wrote:

The immediate problem here is that you've declared the "cat" variable but
never instantiated it - you're missing a "Set cat = New ADOX.Catalog"
line.

Beyond that, you're mixing automation and data access, which are really
two
separate things. What is it you want to do - automate the Access
application, or just get at the data from your .NET code?

--
Brendan Reynolds (MVP)


"Ed White" .(donotspam) wrote in message
...
From VB .Net, using either DAO or ADOX (or whatever else is available),
how
can I obtain a reference to a database file created in Access? For
example,
I tried the following:

Dim AccessApp As New Microsoft.Office.Interop.Access.Application
AccessApp.OpenCurrentDatabase("C:\Documents and
Settings\...\filename.mdb")
Dim cat As ADOX.Catalog
cat.ActiveConnection = AccessApp.CurrentProject.Connection

The last statement gives me a "Object reference not set to an instance
of
an
object" error.
--
Ed






  #5  
Old February 8th, 2005, 11:05 AM
onedaywhen
external usenet poster
 
Posts: n/a
Default


Ed White (donotspam) wrote:
I
got the DDL to work, but I couldn't figure out how to access the .mdb

file in
DAO or ADOX.


Then use DDL g. You could try searching the google groups Usenet
archive for examples e.g.

http://tinyurl.com/4saap

Jamie.

--

  #6  
Old February 8th, 2005, 10:10 PM
Sergey Poberezovskiy
external usenet poster
 
Posts: n/a
Default

Ed,

You have opened database correctly, but forgot to
initialize your ADOX.Catalog object - hence the error.

HTH
-----Original Message-----
From VB .Net, using either DAO or ADOX (or whatever else

is available), how
can I obtain a reference to a database file created in

Access? For example,
I tried the following:

Dim AccessApp As New

Microsoft.Office.Interop.Access.Application
AccessApp.OpenCurrentDatabase("C:\Documents and

Settings\...\filename.mdb")
Dim cat As ADOX.Catalog
cat.ActiveConnection = AccessApp.CurrentProject.Connection

The last statement gives me a "Object reference not set

to an instance of an
object" error.
--
Ed
.

  #7  
Old February 9th, 2005, 12:36 PM
onedaywhen
external usenet poster
 
Posts: n/a
Default

I just re-read your original post. The problem may be a flawed approach
on your part. You seem to be automating the MS Access app and using it
to opening a file, simply to obtain a reference/pointer to an internal
instance of an ADO Connection (note not an OleDb Connection). There is
no need to do this when you can instead create an *external* connection
to the database.

Jamie.

--

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Error Message when opening database eah General Discussion 3 January 26th, 2005 11:04 AM
Using Access 2000 with VB .Net Roger Stenson New Users 0 January 13th, 2005 06:56 PM
Access and VB HS1 General Discussion 2 September 9th, 2004 09:01 PM
Signing a VBA mde/mdb Access 2003 John Buckett General Discussion 3 July 3rd, 2004 09:14 PM


All times are GMT +1. The time now is 03:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.