Create access database on the fly using C# 
Author Message
 Create access database on the fly using C#

Hi,

I'm trying to create an access database at runtime in C# code. The reason
for doing this is in case the user deletes the database and it needs to be
re-created.

 I want to use SQL compliant statement (such as CREATE DATABASE) but for
some reason my code fails.

Looking at the documentation it suggests that I connect to a temporary
database, then use SQL statements to create the new database.  However I get
an exception thrown telling me incorrect syntax.

I can get this working if I use an SQL database, but the application I'm
developing will sit standalone in a number of situtations and I don't want
to have to install SQL on local machines.

Can anybody help?

Thanks

Rob.



Tue, 24 May 2005 00:40:16 GMT  
 Create access database on the fly using C#
Rob,

    You might want to look into using ADOX through COM interop.  It will
allow you to create database structures.  Of course, that means you have to
have the OLE-DB provider installed on the machine, but given that you are
going to need it anyways, this shouldn't be a problem.

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]


Quote:
> Hi,

> I'm trying to create an access database at runtime in C# code. The reason
> for doing this is in case the user deletes the database and it needs to be
> re-created.

>  I want to use SQL compliant statement (such as CREATE DATABASE) but for
> some reason my code fails.

> Looking at the documentation it suggests that I connect to a temporary
> database, then use SQL statements to create the new database.  However I
get
> an exception thrown telling me incorrect syntax.

> I can get this working if I use an SQL database, but the application I'm
> developing will sit standalone in a number of situtations and I don't want
> to have to install SQL on local machines.

> Can anybody help?

> Thanks

> Rob.



Tue, 24 May 2005 00:44:15 GMT  
 Create access database on the fly using C#
One way to handle this is to have a shell database (mdb) stored as a
resource (or file).  Just copy it over, rename it and add/change any
structures you may need.  It is certainly a simple solution.

Mike


Quote:
> Hi,

> I'm trying to create an access database at runtime in C# code. The reason
> for doing this is in case the user deletes the database and it needs to be
> re-created.

>  I want to use SQL compliant statement (such as CREATE DATABASE) but for
> some reason my code fails.

> Looking at the documentation it suggests that I connect to a temporary
> database, then use SQL statements to create the new database.  However I
get
> an exception thrown telling me incorrect syntax.

> I can get this working if I use an SQL database, but the application I'm
> developing will sit standalone in a number of situtations and I don't want
> to have to install SQL on local machines.

> Can anybody help?

> Thanks

> Rob.



Tue, 24 May 2005 03:55:02 GMT  
 Create access database on the fly using C#
Thanks for help, that worked a treat.

Rob.



Quote:
> Rob,

>     You might want to look into using ADOX through COM interop.  It will
> allow you to create database structures.  Of course, that means you have
to
> have the OLE-DB provider installed on the machine, but given that you are
> going to need it anyways, this shouldn't be a problem.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET/C# MVP]



> > Hi,

> > I'm trying to create an access database at runtime in C# code. The
reason
> > for doing this is in case the user deletes the database and it needs to
be
> > re-created.

> >  I want to use SQL compliant statement (such as CREATE DATABASE) but for
> > some reason my code fails.

> > Looking at the documentation it suggests that I connect to a temporary
> > database, then use SQL statements to create the new database.  However I
> get
> > an exception thrown telling me incorrect syntax.

> > I can get this working if I use an SQL database, but the application I'm
> > developing will sit standalone in a number of situtations and I don't
want
> > to have to install SQL on local machines.

> > Can anybody help?

> > Thanks

> > Rob.



Tue, 24 May 2005 20:30:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Creating a Access database using ADOX and C#

2. Creating database on the fly?

3. Creating tables in an access database using ODBC???

4. How to create a new Access database, table, and field using CDaoDatabase, CDasoTableDef

5. create database on-fly

6. Using C# to Access Binary Files Created in C programs

7. Creating C# classes on the fly

8. Create database without using VC++ database tools

9. Problem accessing Access 2000 database using DAO. - URGENT

10. Accessing an MS-Access database file using Visual C++ 4.0

11. C# , i am trying to create a file on the server using C#

12. How to access Custom Database Properties of a Access 97 database programmatically

 

 
Powered by phpBB® Forum Software