| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1201 人关注过本帖
标题:[求助]Datagird 数据库绑定
取消只看楼主 加入收藏
zhuifengjian
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2006-12-31
收藏
 问题点数:0 回复次数:2 
[求助]Datagird 数据库绑定
不显示数据啊!!!!!!!!!!!请各位大侠帮帮忙!!!!!!!!!!!!
先谢谢了!!!!!!!!
Dim conStr As String
Dim conn As OleDbConnection
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim comm As OleDbCommand
Dim comStr As String
conStr = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("book\book.mdb")
conn = New OleDbConnection(conStr)
Try
comStr = "select * from guestbook"
comm = New OleDbCommand(comStr, conn)
da.SelectCommand = comm
conn.Open()
da.Fill(ds, "myinfo")
Catch ex As Exception
If Not ds.Tables Is Nothing Then
DataGrid1.DataSource = ds
DataGrid1.DataBind()
conn.Close()
End If
End Try
搜索更多相关主题的帖子: 数据库 绑定 Datagird Dim 
2007-01-01 19:08
zhuifengjian
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2006-12-31
收藏
得分:0 

谢谢大哥拉!!!!!!!!!!!
小弟初接触ASP
不过又出 了个问题!!!!!!!!!!!!!!!
从类型“DBNull”到类型“Boolean”的强制转换无效
异常详细信息: System.InvalidCastException: 从类型“DBNull”到类型“Boolean”的强制转换无效。

源错误:


行 71: If Not ds.Tables Is Nothing Then
行 72: DataGrid1.DataSource = ds
行 73: DataGrid1.DataBind()
行 74: conn.Close()
行 75: End If


代码:
Dim conStr As String
Dim conn As OleDbConnection
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim comm As OleDbCommand
Dim comStr As String
conStr = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("book\book.mdb")
conn = New OleDbConnection(conStr)
Try
comStr = "select * from guestbook"
comm = New OleDbCommand(comStr, conn)
da.SelectCommand = comm
conn.Open()
da.Fill(ds, "myinfo")
DataGrid1.DataSource = da.TableMappings("myinfo")
Catch ex As Exception
If Not ds.Tables Is Nothing Then
DataGrid1.DataSource = ds
DataGrid1.DataBind()
conn.Close()
End If

End Try

2007-01-02 18:38
zhuifengjian
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2006-12-31
收藏
得分:0 

谢谢各位老大拉!!!!!!!!1

2007-01-04 17:16
快速回复:[求助]Datagird 数据库绑定
数据加载中...
 
   



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

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