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

  • Thread starter Thread starter Null Reference
  • Start date Start date
N

Null Reference

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
 
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.
 
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
 
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(


Cool!

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

Jon

Null Reference said:
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



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"

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



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"

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


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
 
Compress it. J# has zipping ability. Zipped access files compress by as much
as 99%.

Jon


MsJuLiE said:
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(


Cool!

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

Jon

Null Reference said:
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



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"

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



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"

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


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
 
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 said:
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(


Cool!

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

Jon

Null Reference said:
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



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"

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



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"

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


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
 
see attachment

Jon


Jon Davis said:
Ehhh .. see attached file, which is only 96KB. Where are you getting your
40MB?

The template file should be BLANK (no tables)!

Jon


MsJuLiE said:
It's nice but now I'm entertaining the template idea you mentioned.
The result DB file was 40MB as opposed to 3 MB :(


Cool!

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

Jon

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



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"

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
my
code
file
 
Back
Top