首页蓝耳朵|小小蓝耳朵广州图书馆外文室英语儿童读物资源介绍网佛教青年之友旧版收集永硕E盘Phonics Short Vowels Game 
在SqlDataSource控件的参数里,尽量用Type属性,少用DbType属性
所属栏目:ASP.NET(webform)  时间:2010-11-13 10:00  作者:狼子

就是要记住这句话,用Type属性,少用DbType属性,因为现在很多服务器没有安装.net frameworkk 3.5,如果用了DbType,会出现报错:

类型“System.Web.UI.WebControls.ControlParameter”不具有名为“DbType”的公共属性。

或者:

'System.Web.UI.WebControls.Parameter' does not have a public property named 'DbType'

我查不到原因,这里有一个帖子:

http://forums.asp.net/t/1286923.aspx

If you look closer at the error, it is telling you what is wrong.  You are trying to access the database, but the error mentions a 'System.Web.UI.WebControls.Parameter'  type.  You should be using an IDataParameter or IDbDataParameter.  (That's the interface that specialized classes implement, e.g., System.Data.SqlClient.SqlParameter implements both interfaces.)

Maybe there is a discrepancy between the datatype declared and how it is implemented at the host?

查了好多,都是说要就升级服务器到3.5 sp1,要就改用Type,程序员对服务器没有控制权,最好是用Type,不要用DbType了

就是,这是为什么呢?我的机器上装了vs.net2005、vs.net2008,我以为是因为DbType在System.Data.SqlClient.SqlParameter里满足两个接口,所以会出现在上下文菜单里,就是,小燕子的机器只有vs.net2005,没有装.net framework3.5,她的上下文菜单里,一样子有DbType属性

我一直更愿意用DbType的,因为我用的是MS SQL数据库,现在要记住换掉,要用.net自己的Type

小楼宝宝的涂鸦花花(Imitater)的博客起名称骨测字皖ICP备06000023号-17