471,355 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

How do you create a Access Database for a setup project

Hi, I am developing a c# windows .NET application. The application is going
to run on a standalone PC and use an access database. I have figured out that
I will need to create a project and add it to the custom actions of the my
setup project to create the database.

How do I create the database and then add a table using C#? Also, should I
use an odbc data adapter, which I usually use with Access and if so how do I
register the new database I have just created from my custom action project
as an ODBC database.

Any help would be greatly appreciated, I imagine the answer to this question
could help quite a lot of people who use Windows Apps/Access for small
projects and want to create an installer for them.
Feb 8 '06 #1
4 3279
Hello Paul,

Add reference to the COM lib "Microsoft ADO Ext 2.8 for DLL and security"
located \program files\Common Files\System\Ado\msADOX.dll

using ADOX;
Catalog cat = new Catalog();
strCreateDB += "Provider=Microsoft.Jet.OLEDB.4.0;";
strCreateDB += "Data Source=" + pstrDB + ";";
strCreateDB += "Jet OLEDB:Engine Type=5";
cat.Create(@"c:\test.mdb"1);

P> Hi, I am developing a c# windows .NET application. The application is
P> going to run on a standalone PC and use an access database. I have
P> figured out that I will need to create a project and add it to the
P> custom actions of the my setup project to create the database.
P>
P> How do I create the database and then add a table using C#? Also,
P> should I use an odbc data adapter, which I usually use with Access
P> and if so how do I register the new database I have just created from
P> my custom action project as an ODBC database.
P>
P> Any help would be greatly appreciated, I imagine the answer to this
P> question could help quite a lot of people who use Windows Apps/Access
P> for small projects and want to create an installer for them.
P>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 8 '06 #2
On Wed, 8 Feb 2006 18:34:08 +0000 (UTC), Michael Nemtsev
<ne*****@msn.com> wrote:
Hello Paul,

Add reference to the COM lib "Microsoft ADO Ext 2.8 for DLL and security"
located \program files\Common Files\System\Ado\msADOX.dll

using ADOX;
Catalog cat = new Catalog();
strCreateDB += "Provider=Microsoft.Jet.OLEDB.4.0;";
strCreateDB += "Data Source=" + pstrDB + ";";
strCreateDB += "Jet OLEDB:Engine Type=5";
cat.Create(@"c:\test.mdb"1);

P> Hi, I am developing a c# windows .NET application. The application is
P> going to run on a standalone PC and use an access database. I have
P> figured out that I will need to create a project and add it to the
P> custom actions of the my setup project to create the database.
P>
P> How do I create the database and then add a table using C#? Also,
P> should I use an odbc data adapter, which I usually use with Access
P> and if so how do I register the new database I have just created from
P> my custom action project as an ODBC database.
P>
P> Any help would be greatly appreciated, I imagine the answer to this
P> question could help quite a lot of people who use Windows Apps/Access
P> for small projects and want to create an installer for them.
P>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Or reference DAO in your project and build the DB with DAO.

Or use a template database and copy it each time you create a new DB
and change it's name

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Feb 9 '06 #3
Otis Mukinfus wrote:
Or reference DAO in your project and build the DB with DAO.


I think we were supposed to stop using DAO about 5 years ago...
--
jc

Remove the -not from email
Feb 9 '06 #4
On Thu, 09 Feb 2006 09:37:10 GMT, Jeremy Collins
<jd********@ntlworld-not.com> wrote:
Otis Mukinfus wrote:
Or reference DAO in your project and build the DB with DAO.


I think we were supposed to stop using DAO about 5 years ago...


When did those idiots and crooks in Washington DC pass that law?

I have several tools in my tool box and use them all when I need them.
Saying we are supposed to stop using DAO is like saying we're supposed
to stop using arrays because were now have collections and lists.

If we follow your line of reasoning we can't use the first solution
suggested, because it looks like it ends up calling ADOX, which you
must believe we shouldn't use either.

Use the wrench that fits the nut you want to tighten or loosen, even
if it belonged to your grand-daddy.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Feb 9 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Frank Wilson | last post: by
7 posts views Thread by Terry Holland | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.