SqlDbType与DbType类型互相转换
SqlDbType与DbType类型互相转换
扫一扫加作者微信
如果要将System.Data.Dbtype转换为System.Data.SqlDbType,以前以为要写Switch Case语句。其实有很简单的方法:
1. DbType转SqlDbType
C# Code:
private System.Data.SqlDbType DbType2SqlDbType(System.Data.DbType pSourceType)
{
SqlParameter paraConver = new SqlParameter();
paraConver.DbType = pSourceType ;
return paraConver.SqlDbType;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private System.Data.SqlDbType DbType2SqlDbType(System.Data.DbType pSourceType)
{
SqlParameter paraConver = new SqlParameter();
paraConver.DbType = pSourceType ;
return paraConver.SqlDbType;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
2. SqlDbType转DbType
C# Code:
private System.Data.DbType SqlDbType2DbType(System.Data.SqlDbType pSourceType)
{
SqlParameter paraConver = new SqlParameter();
paraConver.SqlDbType = pSourceType;
return paraConver.DbType;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private System.Data.DbType SqlDbType2DbType(System.Data.SqlDbType pSourceType)
{
SqlParameter paraConver = new SqlParameter();
paraConver.SqlDbType = pSourceType;
return paraConver.DbType;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网