472,341 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

HELP with programmatically creating a blank Microsoft Access DB file in C#.NET

Anybody here who can explain or point me to a link ?

I wish to create a blank MS Access DB file programmatically
using C# .
Thanks, nfs
Nov 15 '05 #1
6 13265
I don't want to deal with the Access app in way, shape. or form
though. I am hoping to do this 100% via the C# code.

I found this so far

Programmers often need to create databases programmatically. Although
neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
create Microsoft Access databases automatically, you can use the
Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
Security (ADOX) through the COM Interop layer to create databases
manually

so, this upsets me.
On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
I believe you're missing my answer...

Access is only used once, to generate an empty template. Use C# to copy the
template file to your destination. Shall I create one for you? Shall I make
a C# assembly with this file bundled in it as a resource?

I don't believe Jet offers database file creation services.

Jon
"Null Reference" <Or****@ywam.org> wrote in message
news:2i********************************@4ax.com.. .

I believe you're missing the main question..

I'm wanting to create the Access .mdb file programmatically via my C#
code. I can create the tables and everything already via my C# code to
a blank .mdb file.

I just don't want to use Access to create anything.

nfs

On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>Try this (untested)...
>
>Create a database file in Access.
>Copy the file somewhere. This is a template file.
>When you want to create an Access database, copy the template file towhere >you want it, and rename the file appropriately.
>Use Jet's SQL language to create new tables, etc, over OleDb.
>
>HTH,
>Jon
>
>
>"Null Reference" <Or****@ywam.org> wrote in message
>news:gn********************************@4ax.com.. .
>> Anybody here who can explain or point me to a link ?
>>
>> I wish to create a blank MS Access DB file programmatically
>> using C# .
>>
>>
>> Thanks, nfs
>


Nov 15 '05 #2
Jon,

I figured out how to get it accomplished finally. The internet is damn
vast that weeding through the haystack of pages I finally found the
needle I was looking for..
using System;
using ADOX;

public class CreateDB
{
public static void Main( string [] args )
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();

string create =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=L:\Programming\IO\Convert\LogBook2.mdb;" +
"Jet OLEDB:Engine Type=5";

cat.Create(create);

cat = null;
}

}

Thanks for actually giving some of your time to look at my question!

nfs

On Tue, 22 Jul 2003 07:14:20 GMT, Null Reference <Or****@ywam.org>
wrote:
I don't want to deal with the Access app in way, shape. or form
though. I am hoping to do this 100% via the C# code.

I found this so far

Programmers often need to create databases programmatically. Although
neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
create Microsoft Access databases automatically, you can use the
Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
Security (ADOX) through the COM Interop layer to create databases
manually

so, this upsets me.
On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
I believe you're missing my answer...

Access is only used once, to generate an empty template. Use C# to copy the
template file to your destination. Shall I create one for you? Shall I make
a C# assembly with this file bundled in it as a resource?

I don't believe Jet offers database file creation services.

Jon
"Null Reference" <Or****@ywam.org> wrote in message
news:2i********************************@4ax.com. ..

I believe you're missing the main question..

I'm wanting to create the Access .mdb file programmatically via my C#
code. I can create the tables and everything already via my C# code to
a blank .mdb file.

I just don't want to use Access to create anything.

nfs

On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:

>Try this (untested)...
>
>Create a database file in Access.
>Copy the file somewhere. This is a template file.
>When you want to create an Access database, copy the template file to

where
>you want it, and rename the file appropriately.
>Use Jet's SQL language to create new tables, etc, over OleDb.
>
>HTH,
>Jon
>
>
>"Null Reference" <Or****@ywam.org> wrote in message
>news:gn********************************@4ax.com.. .
>> Anybody here who can explain or point me to a link ?
>>
>> I wish to create a blank MS Access DB file programmatically
>> using C# .
>>
>>
>> Thanks, nfs
>


Nov 15 '05 #3
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(
On Tue, 22 Jul 2003 16:07:33 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
Cool!

I've never worked with the ADOX namespace before... hmm...

Jon

"Null Reference" <Or****@ywam.org> wrote in message
news:an********************************@4ax.com.. .
Jon,

I figured out how to get it accomplished finally. The internet is damn
vast that weeding through the haystack of pages I finally found the
needle I was looking for..
using System;
using ADOX;

public class CreateDB
{
public static void Main( string [] args )
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();

string create =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=L:\Programming\IO\Convert\LogBook2.mdb;" +
"Jet OLEDB:Engine Type=5";

cat.Create(create);

cat = null;
}

}

Thanks for actually giving some of your time to look at my question!

nfs

On Tue, 22 Jul 2003 07:14:20 GMT, Null Reference <Or****@ywam.org>
wrote:
>I don't want to deal with the Access app in way, shape. or form
>though. I am hoping to do this 100% via the C# code.
>
>I found this so far
>
>Programmers often need to create databases programmatically. Although
>neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
>create Microsoft Access databases automatically, you can use the
>Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
>Security (ADOX) through the COM Interop layer to create databases
>manually
>
>so, this upsets me.
>
>
>On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
><jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>
>>I believe you're missing my answer...
>>
>>Access is only used once, to generate an empty template. Use C# to copythe >>template file to your destination. Shall I create one for you? Shall Imake >>a C# assembly with this file bundled in it as a resource?
>>
>>I don't believe Jet offers database file creation services.
>>
>>Jon
>>
>>
>>"Null Reference" <Or****@ywam.org> wrote in message
>>news:2i********************************@4ax.com. ..
>>>
>>> I believe you're missing the main question..
>>>
>>> I'm wanting to create the Access .mdb file programmatically via my C#
>>> code. I can create the tables and everything already via my C# code to
>>> a blank .mdb file.
>>>
>>> I just don't want to use Access to create anything.
>>>
>>> nfs
>>>
>>>
>>>
>>> On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
>>> <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>>>
>>> >Try this (untested)...
>>> >
>>> >Create a database file in Access.
>>> >Copy the file somewhere. This is a template file.
>>> >When you want to create an Access database, copy the template file to
>>where
>>> >you want it, and rename the file appropriately.
>>> >Use Jet's SQL language to create new tables, etc, over OleDb.
>>> >
>>> >HTH,
>>> >Jon
>>> >
>>> >
>>> >"Null Reference" <Or****@ywam.org> wrote in message
>>> >news:gn********************************@4ax.com.. .
>>> >> Anybody here who can explain or point me to a link ?
>>> >>
>>> >> I wish to create a blank MS Access DB file programmatically
>>> >> using C# .
>>> >>
>>> >>
>>> >> Thanks, nfs
>>> >
>>>
>>


Nov 15 '05 #4
Compress it. J# has zipping ability. Zipped access files compress by as much
as 99%.

Jon
"MsJuLiE" <Ms*****@wanadoo.fr> wrote in message
news:sh********************************@4ax.com...
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(
On Tue, 22 Jul 2003 16:07:33 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
Cool!

I've never worked with the ADOX namespace before... hmm...

Jon

"Null Reference" <Or****@ywam.org> wrote in message
news:an********************************@4ax.com.. .
Jon,

I figured out how to get it accomplished finally. The internet is damn
vast that weeding through the haystack of pages I finally found the
needle I was looking for..
using System;
using ADOX;

public class CreateDB
{
public static void Main( string [] args )
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();

string create =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=L:\Programming\IO\Convert\LogBook2.mdb;" +
"Jet OLEDB:Engine Type=5";

cat.Create(create);

cat = null;
}

}

Thanks for actually giving some of your time to look at my question!

nfs

On Tue, 22 Jul 2003 07:14:20 GMT, Null Reference <Or****@ywam.org>
wrote:

>I don't want to deal with the Access app in way, shape. or form
>though. I am hoping to do this 100% via the C# code.
>
>I found this so far
>
>Programmers often need to create databases programmatically. Although
>neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
>create Microsoft Access databases automatically, you can use the
>Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
>Security (ADOX) through the COM Interop layer to create databases
>manually
>
>so, this upsets me.
>
>
>On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
><jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>
>>I believe you're missing my answer...
>>
>>Access is only used once, to generate an empty template. Use C# to copy
the
>>template file to your destination. Shall I create one for you? Shall
Imake
>>a C# assembly with this file bundled in it as a resource?
>>
>>I don't believe Jet offers database file creation services.
>>
>>Jon
>>
>>
>>"Null Reference" <Or****@ywam.org> wrote in message
>>news:2i********************************@4ax.com. ..
>>>
>>> I believe you're missing the main question..
>>>
>>> I'm wanting to create the Access .mdb file programmatically via my

C# >>> code. I can create the tables and everything already via my C# code to >>> a blank .mdb file.
>>>
>>> I just don't want to use Access to create anything.
>>>
>>> nfs
>>>
>>>
>>>
>>> On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
>>> <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>>>
>>> >Try this (untested)...
>>> >
>>> >Create a database file in Access.
>>> >Copy the file somewhere. This is a template file.
>>> >When you want to create an Access database, copy the template file to >>where
>>> >you want it, and rename the file appropriately.
>>> >Use Jet's SQL language to create new tables, etc, over OleDb.
>>> >
>>> >HTH,
>>> >Jon
>>> >
>>> >
>>> >"Null Reference" <Or****@ywam.org> wrote in message
>>> >news:gn********************************@4ax.com.. .
>>> >> Anybody here who can explain or point me to a link ?
>>> >>
>>> >> I wish to create a blank MS Access DB file programmatically
>>> >> using C# .
>>> >>
>>> >>
>>> >> Thanks, nfs
>>> >
>>>
>>

Nov 15 '05 #5
Compress it. J#'s libraries (which you can freely utilize in C#) have a zip
library. Zipped access files compress by as much
as 99%.

Jon

"MsJuLiE" <Ms*****@wanadoo.fr> wrote in message
news:sh********************************@4ax.com...
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(
On Tue, 22 Jul 2003 16:07:33 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
Cool!

I've never worked with the ADOX namespace before... hmm...

Jon

"Null Reference" <Or****@ywam.org> wrote in message
news:an********************************@4ax.com.. .
Jon,

I figured out how to get it accomplished finally. The internet is damn
vast that weeding through the haystack of pages I finally found the
needle I was looking for..
using System;
using ADOX;

public class CreateDB
{
public static void Main( string [] args )
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();

string create =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=L:\Programming\IO\Convert\LogBook2.mdb;" +
"Jet OLEDB:Engine Type=5";

cat.Create(create);

cat = null;
}

}

Thanks for actually giving some of your time to look at my question!

nfs

On Tue, 22 Jul 2003 07:14:20 GMT, Null Reference <Or****@ywam.org>
wrote:

>I don't want to deal with the Access app in way, shape. or form
>though. I am hoping to do this 100% via the C# code.
>
>I found this so far
>
>Programmers often need to create databases programmatically. Although
>neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
>create Microsoft Access databases automatically, you can use the
>Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
>Security (ADOX) through the COM Interop layer to create databases
>manually
>
>so, this upsets me.
>
>
>On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
><jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>
>>I believe you're missing my answer...
>>
>>Access is only used once, to generate an empty template. Use C# to copy
the
>>template file to your destination. Shall I create one for you? Shall
Imake
>>a C# assembly with this file bundled in it as a resource?
>>
>>I don't believe Jet offers database file creation services.
>>
>>Jon
>>
>>
>>"Null Reference" <Or****@ywam.org> wrote in message
>>news:2i********************************@4ax.com. ..
>>>
>>> I believe you're missing the main question..
>>>
>>> I'm wanting to create the Access .mdb file programmatically via my

C# >>> code. I can create the tables and everything already via my C# code to >>> a blank .mdb file.
>>>
>>> I just don't want to use Access to create anything.
>>>
>>> nfs
>>>
>>>
>>>
>>> On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
>>> <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
>>>
>>> >Try this (untested)...
>>> >
>>> >Create a database file in Access.
>>> >Copy the file somewhere. This is a template file.
>>> >When you want to create an Access database, copy the template file to >>where
>>> >you want it, and rename the file appropriately.
>>> >Use Jet's SQL language to create new tables, etc, over OleDb.
>>> >
>>> >HTH,
>>> >Jon
>>> >
>>> >
>>> >"Null Reference" <Or****@ywam.org> wrote in message
>>> >news:gn********************************@4ax.com.. .
>>> >> Anybody here who can explain or point me to a link ?
>>> >>
>>> >> I wish to create a blank MS Access DB file programmatically
>>> >> using C# .
>>> >>
>>> >>
>>> >> Thanks, nfs
>>> >
>>>
>>

Nov 15 '05 #6
see attachment

Jon
"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ehhh .. see attached file, which is only 96KB. Where are you getting your
40MB?

The template file should be BLANK (no tables)!

Jon
"MsJuLiE" <Ms*****@wanadoo.fr> wrote in message
news:sh********************************@4ax.com...
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(
On Tue, 22 Jul 2003 16:07:33 -0700, "Jon Davis"
<jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
Cool!

I've never worked with the ADOX namespace before... hmm...

Jon

"Null Reference" <Or****@ywam.org> wrote in message
news:an********************************@4ax.com.. .
> Jon,
>
> I figured out how to get it accomplished finally. The internet is damn> vast that weeding through the haystack of pages I finally found the
> needle I was looking for..
>
>
> using System;
> using ADOX;
>
> public class CreateDB
> {
> public static void Main( string [] args )
> {
> ADOX.CatalogClass cat = new ADOX.CatalogClass();
>
> string create =
> @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=L:\Programming\IO\Convert\LogBook2.mdb;" +
> "Jet OLEDB:Engine Type=5";
>
> cat.Create(create);
>
> cat = null;
> }
>
> }
>
>
>
>
>
> Thanks for actually giving some of your time to look at my question!
>
> nfs
>
>
>
> On Tue, 22 Jul 2003 07:14:20 GMT, Null Reference <Or****@ywam.org>
> wrote:
>
> >I don't want to deal with the Access app in way, shape. or form
> >though. I am hoping to do this 100% via the C# code.
> >
> >I found this so far
> >
> >Programmers often need to create databases programmatically. Although> >neither ActiveX Data Objects (ADO) nor ADO.NET provide the means to
> >create Microsoft Access databases automatically, you can use the
> >Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and
> >Security (ADOX) through the COM Interop layer to create databases
> >manually
> >
> >so, this upsets me.
> >
> >
> >On Mon, 21 Jul 2003 22:46:21 -0700, "Jon Davis"
> ><jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
> >
> >>I believe you're missing my answer...
> >>
> >>Access is only used once, to generate an empty template. Use C# to copythe
> >>template file to your destination. Shall I create one for you?
Shall
Imake
> >>a C# assembly with this file bundled in it as a resource?
> >>
> >>I don't believe Jet offers database file creation services.
> >>
> >>Jon
> >>
> >>
> >>"Null Reference" <Or****@ywam.org> wrote in message
> >>news:2i********************************@4ax.com. ..
> >>>
> >>> I believe you're missing the main question..
> >>>
> >>> I'm wanting to create the Access .mdb file programmatically via
my
C#> >>> code. I can create the tables and everything already via my C#
code
to> >>> a blank .mdb file.
> >>>
> >>> I just don't want to use Access to create anything.
> >>>
> >>> nfs
> >>>
> >>>
> >>>
> >>> On Mon, 21 Jul 2003 21:24:45 -0700, "Jon Davis"
> >>> <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote:
> >>>
> >>> >Try this (untested)...
> >>> >
> >>> >Create a database file in Access.
> >>> >Copy the file somewhere. This is a template file.
> >>> >When you want to create an Access database, copy the template
file
to> >>where
> >>> >you want it, and rename the file appropriately.
> >>> >Use Jet's SQL language to create new tables, etc, over OleDb.
> >>> >
> >>> >HTH,
> >>> >Jon
> >>> >
> >>> >
> >>> >"Null Reference" <Or****@ywam.org> wrote in message
> >>> >news:gn********************************@4ax.com.. .
> >>> >> Anybody here who can explain or point me to a link ?
> >>> >>
> >>> >> I wish to create a blank MS Access DB file programmatically
> >>> >> using C# .
> >>> >>
> >>> >>
> >>> >> Thanks, nfs
> >>> >
> >>>
> >>
>




Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I...
0
by: Junkguy | last post by:
I need to be able to tell if the blank row of a DataGrid has been edited or not. In a DataGrid, you may notice that if you click on the asterisk...
3
by: R Reyes | last post by:
Just wondering if anyone knows the pros/cons between creating a database programmatically vs using the application's tool windows/features that come...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and...
11
by: Amadrias | last post by:
Hi, In one of my current projects, I am willing to create a secure zone such as Acronis does in its application to store some confidential...
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python...
9
by: Tris | last post by:
Hi People I need help!!! Have got a excel file that i have put into an access file so that i can create a mailing carrier sheet without re...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM...
3
by: ARC | last post by:
I'm having trouble here with Access 2007 and connecting to a different database. The code below works great IF the previous back-end database...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.