Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easier way to accomplish this task...
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Easier way to accomplish this task...
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP1
Network:
Novell 6.x
Database:
MS SQL Server
Miscellaneous
Thread ID:
01018171
Message ID:
01018171
Views:
49
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
Map
View

Click here to load this message in the networking platform