I'm writing code (in VB.NET/2005) to create a SQL Server database from some
"other" database (user selected). So I "connect" to it and then use the
GetSchema method options to retrieve its characteristics to create/define
the new SQL Server database and (optionally) populate it with data from the
old database.
Using the GetSchema("Columns", restrictions) method, I get a data table back
showing the datatypes of the columns in the selected (old) table. They show
up as a number (e.g. a "12" is a varchar) and a name. Then there's the size,
number of decimals etc.
Question is:
Is there a way to use this information to specify the SMO datatype without
having to go through a whole whack of "Select Case" statements to deal with
each separate incoming datatype?
I'm trying to avoid a whole series of statements like this:
Select Case <input datatype number>
Case 12
col.DataType =
Microsoft.SqlServer.Management.Smo.DataType.VarCha r(COLUMN_SIZE)
This does work but it's a lot of coding and there's too great a potential
for missing one (or more) valid case(s)