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
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP1
Network:
Novell 6.x
Database:
MS SQL Server
Miscellaneous
Thread ID:
01018171
Message ID:
01018194
Views:
10
Ty,

How about this:
private System.Data.SqlDbType GetSQLType1(string dataType)
{
	foreach (System.Data.SqlDbType sdt in Enum.GetValues(typeof(System.Data.SqlDbType)))
	{
		if (sdt.ToString().ToLower() == dataType.ToLower())
		{
			return sdt;
		}
	}
		return System.Data.SqlDbType.Variant;
}
HTH,
Chad

>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!!!
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform