运行出现 ...............从类型“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"> <IMG src="images/post.gif" border="0"> <%# DataBinder.Eval(Container.DataItem,"date") %></TD>
<TD class="bg02" align="center" width="120" height="20"><IMG src="images/ip.gif">
<asp:Label id=Label3 runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"ip") %>'>
</asp:Label>
<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: