0
Reply

provider-independant table creation

babak mahmoudian

babak mahmoudian

Jul 12 2009 1:25 AM
2k
hi everybody,

I'm writing a Form/Report generator system using C# and .Net 3.5.

since the program is supposed to work with almost all of the database systems available(SQLServer, Oracle, Access, ...), i need to make my code independant of providers.

it worked fine with creating DBConnections and DataAdapters. and I guess it's going to be fine with insert, update and delete statements(since I'm going to use the CommandBuilder object).

the main problem is when I want to create a new table or alter an already existing table. since I wouldn't know the type of the database I would have to check the DBType and write some specific SQL. for example I have to consider the DataTypes (in SQLServer: nvarchar, int, bit, ... and in Oracle: varchar2, number, not having boolean, ...)
the main problem of this approach is the lack of performance, since i have to use some If or Switch statements to check the DBType and do some String related stuff to form different SQL statements corresponding to different DBTypes.

now I was wondering if there was some built-in classes or methods to create and alter tables.


thank you everybody!