[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Create a new mdb (Access Database) from the code in Visual Basic (visual studio express)

Posted on 2010-04-02
12
Medium Priority
?
579 Views
Last Modified: 2013-12-20
Hi.

I  am writing a vb application that needs to be able to work from several access databases.  The data bases will be essentially the same just different accounts so to speak.

This means I will need to be able to create a new blank database from  the code if the user chooses to add another account.   How would I do this?  I'm a bit new to visual studio so take it slow.

It doesn't have to be an access database. that's just what i'm used to working with.

Best regards
0
Comment
Question by:rowanscott
  • 6
  • 6
12 Comments
 
LVL 48

Expert Comment

by:Jorge Paulino
ID: 29437531
Why don't you have a template (empty database) and just make a copy when required?
0
 
LVL 4

Author Comment

by:rowanscott
ID: 29439388
That's a good idea.  Do you know how to make a copy with vb code or how to include the template with the installer.
0
 
LVL 48

Expert Comment

by:Jorge Paulino
ID: 29439655
In the installer you can include the database and for copy you just need to do IO.File.Copy(sourceFile,destFile)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 4

Author Comment

by:rowanscott
ID: 29440215
Do I make the mdb database manually first using Microsoft Access.  Sorry I'm very new to visual studio.  I have done lots of vba in excel though so I'm hoping I will pick it up before too long.
0
 
LVL 48

Expert Comment

by:Jorge Paulino
ID: 29440317
>> Do I make the mdb database manually first using Microsoft Access
Yes, it's the easy way! :)
0
 
LVL 4

Author Comment

by:rowanscott
ID: 29441875
OK.

I know how to use an mdb from excel's vba but i'm sure there would be a better way in visual studio.

Can you give me any clues.
0
 
LVL 4

Author Comment

by:rowanscott
ID: 29548633
I'm not getting this.  I've made the mdb database and embedded it.  

I cant even work out how to read and write to an embedded text file yet.  How do you refer to text files (i will get onto the database later) if they are embedded because you don't know their full address.

Sorry to be so slow!

0
 
LVL 48

Accepted Solution

by:
Jorge Paulino earned 2000 total points
ID: 29562008
>> I've made the mdb database and embedded it.
You have embedded it? In the resources?
If so you need to extract for a specific location. Check this blog post http://vbtuga.blogspot.com/2009/04/vbnet-extraindo-executaveis-dos.html
It's in Portuguese (it's my blog) but I think you understand the code. You can extract the db to a place you define and then work with her.
0
 
LVL 4

Author Comment

by:rowanscott
ID: 29633357
Yippee, thanks jpaulino

Now I can just make copies of the database whenever the user wants to add an account.

I still need to keep a record of what accounts have been added which I thought to do in an "Accounts.txt" file in the resources but your help has solved my original question.

I've used your function so I'm proud to have some resident Portuguese comments in my application now!

 
0
 
LVL 4

Author Closing Comment

by:rowanscott
ID: 31710204
Thanks very much.
0
 
LVL 48

Expert Comment

by:Jorge Paulino
ID: 29649024
Glad I could help and I think the Portuguese comments will look nice on your application :)
Cheers!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question