Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Easier way to accomplish this task...
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Easier way to accomplish this task...
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP1
Network:
Novell 6.x
Database:
MS SQL Server
Divers
Thread ID:
01018171
Message ID:
01018171
Vues:
50
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!!!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform