Click here to Skip to main content
16,023,117 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a installer to generate database and tables on server automatically.This application works fine only with sql server.
I have to generalize the same application for various dbs like oracle,db2,etc.
I have written the application in c#.
for this i have create a text file which contains script for genrating db and its tables.My problem is:executing sql statement one by one from this file

following is the content of the file
/*****************************************************************

SQL
CREATE DATABASE [Info]
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
USE [Info]
GO
CREATE TABLE [dbo].[Employees] (
[Name] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Rsvp] [int] NULL ,
[Requests] [nvarchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY];

ALTER TABLE [dbo].[Employees] WITH NOCHECK ADD
CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED
(
[Name]
) ON [PRIMARY];



*******************************************************************/
please help me for the same.

Regards,
Amol
Posted
Comments
AmolNagarkar 10-May-10 2:27am    
hey plz also tell me.
the scripts for creating db and its tables will be same for each dataprovider or diffrent???

thanks for th answers b4

If you want to support all databases, then you need to use strict SQL and no specific features. If you want to use different features in different DBs, you need to deploy a script for each DB.
 
Share this answer
 
While .NET provides you with some great facilities with regards to Providers, there are some things that are simply outside the scope of the factories. Here you have an implementation that you want to target multiple databases from the same creation script - sorry to say that you can't do this simply.

Each database vendor has their own unique flavour when it comes to creating databases/tables. What you would need to do is code a factory class that analyzed some form of intermediate step and then generated database specific code. This is a none-trivial task.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900