// sql server数据类型(如:varchar) // 转换为SqlDbType类型 public static SqlDbType SqlTypeString2SqlType(string sqlTypeString) { SqlDbType dbType = SqlDbType.Variant;//默认为Object switch (sqlTypeString) { case "int": dbType = SqlDbType.I
// sql server数据类型(如:varchar)
// 转换为sqldbtype类型
public static sqldbtype sqltypestring2sqltype(string sqltypestring)
{
sqldbtype dbtype = sqldbtype.variant;//默认为object
switch (sqltypestring)
{
case "int":
dbtype = sqldbtype.int;
break;
case "varchar":
dbtype = sqldbtype.varchar;
break;
case "bit":
dbtype = sqldbtype.bit;
break;
case "datetime":
dbtype = sqldbtype.datetime;
break;
case "decimal":
dbtype = sqldbtype.decimal;
break;
case "float":
dbtype = sqldbtype.float;
break;
case "image":
dbtype = sqldbtype.image;
break;
case "money":
dbtype = sqldbtype.money;
break;
case "ntext":
dbtype = sqldbtype.ntext;
break;
case "nvarchar":
dbtype = sqldbtype.nvarchar;
break;
case "smalldatetime":
dbtype = sqldbtype.smalldatetime;
break;
case "smallint":
dbtype = sqldbtype.smallint;
break;
case "text":
dbtype = sqldbtype.text;
break;
case "bigint":
dbtype = sqldbtype.bigint;
break;
case "binary":
dbtype = sqldbtype.binary;
break;
case "char":
dbtype = sqldbtype.char;
break;
case "nchar":
dbtype = sqldbtype.nchar;
break;
case "numeric":
dbtype = sqldbtype.decimal;
break;
case "real":
dbtype = sqldbtype.real;
break;
case "smallmoney":
dbtype = sqldbtype.smallmoney;
break;
case "sql_variant":
dbtype = sqldbtype.variant;
break;
case "timestamp":
dbtype = sqldbtype.timestamp;
break;
case "tinyint":
dbtype = sqldbtype.tinyint;
break;
case "uniqueidentifier":
dbtype = sqldbtype.uniqueidentifier;
break;
case "varbinary":
dbtype = sqldbtype.varbinary;
break;
case "xml":
dbtype = sqldbtype.xml;
break;
}
return dbtype;
}
// SqlDbType转换为C#数据类型
public static Type SqlType2CsharpType(SqlDbType sqlType)
{
switch (sqlType)
{
case SqlDbType.BigInt:
return typeof(Int64);
case SqlDbType.Binary:
return typeof(Object);
case SqlDbType.Bit:
return typeof(Boolean);
case SqlDbType.Char:
return typeof(String);
case SqlDbType.DateTime:
return typeof(DateTime);
case SqlDbType.Decimal:
return typeof(Decimal);
case SqlDbType.Float:
return typeof(Double);
case SqlDbType.Image:
return typeof(Object);
case SqlDbType.Int:
return typeof(Int32);
case SqlDbType.Money:
return typeof(Decimal);
case SqlDbType.NChar:
return typeof(String);
case SqlDbType.NText:
return typeof(String);
case SqlDbType.NVarChar:
return typeof(String);
case SqlDbType.Real:
return typeof(Single);
case SqlDbType.SmallDateTime:
return typeof(DateTime);
case SqlDbType.SmallInt:
return typeof(Int16);
case SqlDbType.SmallMoney:
return typeof(Decimal);
case SqlDbType.Text:
return typeof(String);
case SqlDbType.Timestamp:
return typeof(Object);
case SqlDbType.TinyInt:
return typeof(Byte);
case SqlDbType.Udt://自定义的数据类型
return typeof(Object);
case SqlDbType.UniqueIdentifier:
return typeof(Object);
case SqlDbType.VarBinary:
return typeof(Object);
case SqlDbType.VarChar:
return typeof(String);
case SqlDbType.Variant:
return typeof(Object);
case SqlDbType.Xml:
return typeof(Object);
default:
return null;
}
}
代码:
技术上面应用了三层结构,AJAX框架,URL重写等基础的开发。并用了动软的代码生成器及数据访问类,加进了一些自己用到的小功能,算是整理了一些自己的操作类。系统设计上面说不出用什么模式,大体设计是后台分两级分类,设置好一级之后,再设置二级并选择栏目类型,如内容,列表,上传文件,新窗口等。这样就可以生成无限多个二级分类,也就是网站栏目。对于扩展性来说,如果有新的需求可以直接加一个栏目类型并新加功能操作
0
// sql server中的数据类型,转换为C#中的类型类型
public static Type SqlTypeString2CsharpType(string sqlTypeString)
{
SqlDbType dbTpe = SqlTypeString2SqlType(sqlTypeString);
return SqlType2CsharpType(dbTpe);
}
// 将sql server中的数据类型,转化为C#中的类型的字符串
public static string SqlTypeString2CsharpTypeString(string sqlTypeString)
{
Type type = SqlTypeString2CsharpType(sqlTypeString);
return type.Name;
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号