money to decimal 数据库有一字段,类型为money使用DataReader读取的时候提示转换失败。decimal dec = objDataReader.GetDecimal(0); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题 解决方法有一个把money 类型转换为float类型看看 哦 你这样转换为decimal应该是没有问题的 参考: /// <summary> /// 数据库中与c#中的数据类型对照 /// </summary> /// <param name="type"></param> /// <returns></returns> private string changetocsharptype(string type) { string reval = string.empty; switch (type.tolower()) { case "int": reval = "int32"; break; case "text": reval = "string"; break; case "bigint": reval = "int64"; break; case "binary": reval = "system.byte[]"; break; case "bit": reval = "boolean"; break; case "char": reval = "string"; break; case "datetime": reval = "system.datetime"; break; case "decimal": reval = "system.decimal"; break; case "float": reval = "system.double"; break; case "image": reval = "system.byte[]"; break; case "money": reval = "system.decimal"; break; case "nchar": reval = "string"; break; case "ntext": reval = "string"; break; case "numeric": reval = "system.decimal"; break; case "nvarchar": reval = "string"; break; case "real": reval = "system.single"; break; case "smalldatetime": reval = "system.datetime"; break; case "smallint": reval = "int16"; break; case "smallmoney": reval = "system.decimal"; break; case "timestamp": reval = "system.datetime"; break; case "tinyint": reval = "system.byte"; break; case "uniqueidentifier": reval = "system.guid"; break; case "varbinary": reval = "system.byte[]"; break; case "varchar": reval = "string"; break; case "variant": reval = "object"; break; default: reval = "string"; break; } return reval; } 防止用户修改页面参数访问权限外的信息? 讨论一下此功能的设计 存储过程问题 哪些原因会运行ExecuteReader而抛出"连接被关闭"的异常? c#打印条形码 查找文本是的<img > or <img /> tag 哪位将这段代码转成VB.net code 高手解决asp.net2008 web gridview 的多表头前几列固定问题 一个关于GridView导出EXCEL 数据库取值问题,,,50分求助 谈一下一个简单的算法!时间!菜鸟都懂的! 怎样在安装程序里面修改sqlexpress的sa用户
把money 类型转换为float类型看看
/// 数据库中与c#中的数据类型对照
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private string changetocsharptype(string type)
{
string reval = string.empty;
switch (type.tolower())
{
case "int":
reval = "int32";
break;
case "text":
reval = "string";
break;
case "bigint":
reval = "int64";
break;
case "binary":
reval = "system.byte[]";
break;
case "bit":
reval = "boolean";
break;
case "char":
reval = "string";
break;
case "datetime":
reval = "system.datetime";
break;
case "decimal":
reval = "system.decimal";
break;
case "float":
reval = "system.double";
break;
case "image":
reval = "system.byte[]";
break;
case "money":
reval = "system.decimal";
break;
case "nchar":
reval = "string";
break;
case "ntext":
reval = "string";
break;
case "numeric":
reval = "system.decimal";
break;
case "nvarchar":
reval = "string";
break;
case "real":
reval = "system.single";
break;
case "smalldatetime":
reval = "system.datetime";
break;
case "smallint":
reval = "int16";
break;
case "smallmoney":
reval = "system.decimal";
break;
case "timestamp":
reval = "system.datetime";
break;
case "tinyint":
reval = "system.byte";
break;
case "uniqueidentifier":
reval = "system.guid";
break;
case "varbinary":
reval = "system.byte[]";
break;
case "varchar":
reval = "string";
break;
case "variant":
reval = "object";
break;
default:
reval = "string";
break;
}
return reval;
}