标题:[求助]asp.net 编译时出现从类型“DBNull”到类型“Boolean”的强制转换无效 ...
取消只看楼主
zhuifengjian
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2006-12-31
 问题点数:0 回复次数:0 
[求助]asp.net 编译时出现从类型“DBNull”到类型“Boolean”的强制转换无效

运行出现 ...............从类型“DBNull”到类型“Boolean”的强制转换无效
代码如下....

Dim conn As OleDbConnection
Dim conStr As String

conStr = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("book\book.mdb")
conn = New OleDbConnection(conStr)

Dim comm As OleDbCommand
Dim comStr As String
comStr = "select id,name,cch,email,ggmm,home,content,qq,date,hf,hfm,hf_date,ip,vup from guestbook"
comm = New OleDbCommand(comStr, conn)

Dim da As New OleDbDataAdapter
Dim ds As New DataSet
da.SelectCommand = comm
conn.Open()
da.Fill(ds, "myinfo") '执行selectComma
DataGrid1.DataSource = ds
DataGrid1.DataBind() '将数据集"ds"绑定到DataGrid1

HTML代码如下:
<asp:Panel id=Pcontent runat="server" Visible='<%# DataBinder.Eva(Container.DataItem,"cch") %>'>
<TABLE cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<TR>
<TD class="bg02" width="280" height="20">&nbsp;<IMG src="images/post.gif" border="0">&nbsp;<%# DataBinder.Eval(Container.DataItem,"date") %></TD>
<TD class="bg02" align="center" width="120" height="20"><IMG src="images/ip.gif">&nbsp;
<asp:Label id=Label3 runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"ip") %>'>
</asp:Label>&nbsp;
<asp:Label id="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"vup".ToString()) %>' CssClass="ding">
</asp:Label>
</TD>
</TR>
</TABLE>
</asp:Panel>

错误信息:
异常详细信息: System.InvalidCastException: 从类型“DBNull”到类型“Boolean”的强制转换无效。

源错误:


行 43: da.Fill(ds, "myinfo") '执行selectComma
行 44: DataGrid1.DataSource = ds
行 45: DataGrid1.DataBind() '将数据集"ds"绑定到DataGrid1
行 46: End Sub
行 47:

搜索更多相关主题的帖子: Boolean DBNull 类型 asp 编译 
2006-12-31 17:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-113448-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.095779 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved