|
-
Feb 6th, 2019, 06:54 AM
#1
Thread Starter
Addicted Member
How to open Access 2000(mdb) file with button click in VB.NET project?
My application is old, and it was upgraded to VB.NET from VB6.
There is a need to open an Access 2000 file, but I am not sure where to start in VB.NET code?
Is it possible?
I am using Visual Studio 2005.
In C# 4 there is "dynamic" keyword which I used to open "xls" file. Is there something similar in VB.NET ?
What to put in the click event? Any tutorials on the topic, "open Access file in VB.NET and WinForms"?
Code:
Public Class Form1
Private Sub openAccessFileBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openAccessFileBtn.Click
End Sub
End Class
Note: I was handling this by creating an installer with VS 2005 installation project. When installing, the program created two icons on desktop. One to open the application itself, and the second icon was to open the *.mdb file.
Last edited by kutlesh; Feb 6th, 2019 at 07:14 AM.
-
Feb 6th, 2019, 07:35 AM
#2
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
What exactly do you mean by "open an Access 2000 file"? If you mean the equivalent of double-clicking the file in Explorer then you simply call Process.Start and pass the file path. If you mean that you want to read data from the database then you would use ADO.NET to make a connection and execute SQL queries.
-
Feb 6th, 2019, 07:40 AM
#3
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
 Originally Posted by kutlesh
In C# 4 there is "dynamic" keyword which I used to open "xls" file. Is there something similar in VB.NET ?
You certainly did not use the 'dynamic' keyword to open an XLS file. You may have used the 'dynamic' keyword in the code, which probably suggests that you were using Office Automation. Office Automation has been going on in VB.NET since its inception. The 'dynamic' keyword was introduced in C# in order to support late-binding, which has been supported in VB.NET - it's on by default - since the very first version.
That said, Office Automation to work with an Access file would be very unusual. You basically remote control an instance of the Office application, performing tasks that the user would normally do via the UI. Given that MDB files are just databases, there's no good reason to automate Access when you have ADO.NET available.
-
Feb 6th, 2019, 08:02 AM
#4
Thread Starter
Addicted Member
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
 Originally Posted by jmcilhinney
You certainly did not use the 'dynamic' keyword to open an XLS file. You may have used the 'dynamic' keyword in the code, which probably suggests that you were using Office Automation. Office Automation has been going on in VB.NET since its inception. The 'dynamic' keyword was introduced in C# in order to support late-binding, which has been supported in VB.NET - it's on by default - since the very first version.
That said, Office Automation to work with an Access file would be very unusual. You basically remote control an instance of the Office application, performing tasks that the user would normally do via the UI. Given that MDB files are just databases, there's no good reason to automate Access when you have ADO.NET available.
Yes, I mean Office automation, i.e opening the *.mdb file itself but triggering the open action from a VB.NET button.
The people here are not tech savvy, so a just "open file button" would be useful.
I don't want to use third party components inside my VB.NET/WinForms application just to browse or insert/update data to Access tables. Access 2000 IDE is enough itself.
Since dynamic is supported, probably IDisposable pattern/interface?
A code snippet would be nice since I don't know what to call inside an Access application. For example in Excel you call to Workbooks, in Word you call Documents.
What would it be in Access, Applications, Tables ?
-
Feb 6th, 2019, 08:11 AM
#5
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
 Originally Posted by kutlesh
I don't want to use third party components inside my VB.NET/WinForms application just to browse or insert/update data to Access tables.
Who said anything about third-party components? I recommended ADO.NET, which is the core data access technology for the .NET platform.
 Originally Posted by kutlesh
Access 2000 IDE is enough itself.
I can't see any reason that you would choose to automate the Access UI when using ADO.NET is much, much simpler.
 Originally Posted by kutlesh
A code snippet would be nice since I don't know what to call inside an Access application. For example in Excel you call to Workbooks, in Word you call Documents.
What would it be in Access, Applications, Tables ? 
I've never seen an example of Access automation, probably because pretty much no one does it because there's no real point to doing so. If you're really determined though, nothing is stopping you from referencing the appropriate object library and exploring it for yourself, probably starting in the Object Browser window.
-
Feb 6th, 2019, 08:30 AM
#6
Thread Starter
Addicted Member
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
You are right. Its just that employees here are used to using old technologies and never try to improve their work and automate workflow, sadly. The company spends money to buy Visual Studio 2005, 2008, 2010 and 2017, but the employees still develop applications in MS Access(Going to shoot my self!!). They don't even know how to use the tools they spend money on.
We have SQL Server 2008 and recently SQL Server 2017. I asked why we don't migrate the tables where data is saved, from IBM DB2 32bit server to SQL 2008, or even SQL 2017. I didn't get an answer.
But its ok, since opening Access file in VB.NET is not common workflow, I might jump all over it, and wait for the right time(several light years probably :P ) to rework the application to work with SQL server.
-
Feb 6th, 2019, 10:17 AM
#7
Re: How to open Access 2000(mdb) file with button click in VB.NET project?
I believe what you want (the file to be opened by Access since that is what your users are used to) is what John already wrote in post #2.
[In the openAccessFileBtn_Click routine] call Process.Start and pass the file path
As long as the user has the .mdb file extension associated with Access, it will open in Access as if they had double-clicked on the file themselves.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|