How do you create a Access Database for a setup project

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top