General information
Category:
The Mere Mortals .NET Framework
Title:
Easier way to accomplish this task...
This really is not a MM question but it is a transition from FoxPro to .NET question.
I know how I do this in FoxPro but is there an easier way to perform this type of process:
protected System.Data.SqlDbType GetSQLType(string dataType)
{
System.Data.SqlDbType dbType;
switch (dataType.ToLower().Trim())
{
case "int":
dbType = System.Data.SqlDbType.Int;
break;
case "char":
dbType = System.Data.SqlDbType.Char;
break;
case "bit":
dbType = System.Data.SqlDbType.Bit;
break;
case "decimal":
dbType = System.Data.SqlDbType.Decimal;
break;
case "nvarchar":
dbType = System.Data.SqlDbType.NVarChar;
break;
case "datetime":
dbType = System.Data.SqlDbType.DateTime;
break;
case "smalldatetime":
dbType = System.Data.SqlDbType.SmallDateTime;
break;
case "tinyint":
dbType = System.Data.SqlDbType.TinyInt;
break;
default:
dbType = System.Data.SqlDbType.VarChar;
break;
}
return dbType;
}
The parameter datatype will ALWAYS have a value that is located in the System.Data.SqlDbType enumeration. ALWAYS!!!
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only