[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

how to create a new database from c#

Sam Jost

2/26/2002 10:18:00 PM

Hi!

I want to write a program that creates an .jet database with c#, but I can't
find how to create a database, only how to open it.

OleDbConnection MyConnection= new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=MyDb.mdb");
MyConnection.Open( );

just throws an exception because MyDb.mdb does not exist.

But I need a call to create MyDb.mdb - has anybody out there an idea how to
create a database from c#???

It won't help me to create one with access, I can't do that every time I
need one, I have to be able to do this fromthe program itself.

any help would be appreciated!
Sam


3 Answers

Bob Beauchemin

2/26/2002 10:32:00 PM

0

An Access database? How about ADOX or DAO through interop?
IDBDataSourceAdmin is not exposed by the OleDb data provider.

Bob Beauchemin
bobb@develop.com

"Sam Jost" <sam.news@b-soft.de> wrote in message
news:a5gu33$nof$1@olaf.komtel.net...
> Hi!
>
> I want to write a program that creates an .jet database with c#, but I
can't
> find how to create a database, only how to open it.
>
> OleDbConnection MyConnection= new OleDbConnection(
> "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=MyDb.mdb");
> MyConnection.Open( );
>
> just throws an exception because MyDb.mdb does not exist.
>
> But I need a call to create MyDb.mdb - has anybody out there an idea how
to
> create a database from c#???
>
> It won't help me to create one with access, I can't do that every time I
> need one, I have to be able to do this fromthe program itself.
>
> any help would be appreciated!
> Sam
>
>


Sam Jost

2/26/2002 11:56:00 PM

0

Uuh, you lost me there, I don't know nothing about ADOX or DAO or interop.
I can just guess from your post that you know of no way to create db's from
OleDb, and in ADOX/DAO are ways having to do with some IDBDataSourceAdmin
call?

Sam [confused]

"Bob Beauchemin" <no_bobb_spam@develop.com> schrieb im Newsbeitrag
news:uZGo1zwvBHA.1528@tkmsftngp02...
> An Access database? How about ADOX or DAO through interop?
> IDBDataSourceAdmin is not exposed by the OleDb data provider.
>
> Bob Beauchemin
> bobb@develop.com
>
> "Sam Jost" <sam.news@b-soft.de> wrote in message
> news:a5gu33$nof$1@olaf.komtel.net...
> > Hi!
> >
> > I want to write a program that creates an .jet database with c#, but I
> can't
> > find how to create a database, only how to open it.
> >
> > OleDbConnection MyConnection= new OleDbConnection(
> > "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=MyDb.mdb");
> > MyConnection.Open( );
> >
> > just throws an exception because MyDb.mdb does not exist.
> >
> > But I need a call to create MyDb.mdb - has anybody out there an idea how
> to
> > create a database from c#???
> >
> > It won't help me to create one with access, I can't do that every time I
> > need one, I have to be able to do this fromthe program itself.
> >
> > any help would be appreciated!
> > Sam
> >
> >
>
>


Bob Beauchemin

2/27/2002 1:04:00 AM

0

Sorry.

IDBDataSourceAdmin is the OLE DB interface that ADOX (an extension to ADO)
uses to allow creation of databases in Access. Since this is not exposed in
the OleDb data provider, you cannot use the OleDb data provider to do this.
You must either use the ADOX library (an extension to ADO) or DAO (Data
Access Objects).

Since these are COM-based libraries, you can use them in .NET through COM
interop. In fact, both are available by selecting "Add Reference" in Visual
Studio and choosing the "COM" tab.

DAO = Microsoft DAO 3.6 Object Library
ADOX = Microsoft ADO Ext. 2.7 for DDL and Security

Hope this helps,
Bob Beauchemin
bobb@develop.com


"Sam Jost" <sam.news@b-soft.de> wrote in message
news:a5h3r8$o1k$1@olaf.komtel.net...
> Uuh, you lost me there, I don't know nothing about ADOX or DAO or interop.
> I can just guess from your post that you know of no way to create db's
from
> OleDb, and in ADOX/DAO are ways having to do with some IDBDataSourceAdmin
> call?
>
> Sam [confused]
>
> "Bob Beauchemin" <no_bobb_spam@develop.com> schrieb im Newsbeitrag
> news:uZGo1zwvBHA.1528@tkmsftngp02...
> > An Access database? How about ADOX or DAO through interop?
> > IDBDataSourceAdmin is not exposed by the OleDb data provider.
> >
> > Bob Beauchemin
> > bobb@develop.com
> >
> > "Sam Jost" <sam.news@b-soft.de> wrote in message
> > news:a5gu33$nof$1@olaf.komtel.net...
> > > Hi!
> > >
> > > I want to write a program that creates an .jet database with c#, but I
> > can't
> > > find how to create a database, only how to open it.
> > >
> > > OleDbConnection MyConnection= new OleDbConnection(
> > > "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=MyDb.mdb");
> > > MyConnection.Open( );
> > >
> > > just throws an exception because MyDb.mdb does not exist.
> > >
> > > But I need a call to create MyDb.mdb - has anybody out there an idea
how
> > to
> > > create a database from c#???
> > >
> > > It won't help me to create one with access, I can't do that every time
I
> > > need one, I have to be able to do this fromthe program itself.
> > >
> > > any help would be appreciated!
> > > Sam
> > >
> > >
> >
> >
>
>