标题:连接Access数据库,就是连不上!
只看楼主
ensr2006
Rank: 2
等 级:新手上路
威 望:3
帖 子:97
专家分:0
注 册:2006-3-28
 问题点数:0 回复次数:1 
连接Access数据库,就是连不上!

我试验一个连接Access数据库的例子,结果报这样的错:
Compilation Error
Description:
An error occurred during the compilation of a resource required to service this request. Please review the specific error details below and modify your source code appropriately.

Compiler Error Message: BC30466: The namespace or type 'OleDb' for the import 'System.Data.OleDb' cannot be found.

Source Error:

Line 1: <%@Import Namespace="System.Data"%>
Line 2: <%@Import Namespace="System.Data.OleDb"%>
Line 3: <script language="vb" runat="server">
Line 4: sub page_load(sender as object,e as eventargs)



代码如下:

<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<script language="vb" runat="server">
sub page_load(sender as object,e as eventargs)
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath

("../database/www_news.mdb"))
Dim cmd As New OleDbCommand("select * from news order by sj desc",conn)
conn.Open()
Dim dr As OleDbDataReader=cmd.ExecuteReader()
message.text="<table width='80%' border='1'><tr bgcolor='#CDCDCD'><td>ID</td>
<td>类型</td><td>标题</td><td>作者</td><td>提交时间</td></tr>"
do while dr.read()
message.text &="<tr>"
message.text &="<tr>"&dr.item("isbn")&"</td>"
message.text &="<tr>"&dr.item("lx")&"</td>"
message.text &="<tr>"&dr.item("bt")&"</td>"
message.text &="<tr>"&dr.item("zh")&"</td>"
message.text &="<tr>"&dr.item("sj")&"</td>"
message.text &="<tr>"
loop
message.text&="</table>"
conn.close()
end sub
</script>
<html>
<body>
<h4 align="center">新闻目录</h4>
<center><asp:label id="message" runat="server"/></center>
</body>
</html>

搜索更多相关主题的帖子: 数据库 Access 
2006-09-01 11:34
沙僧
Rank: 1
等 级:新手上路
帖 子:160
专家分:0
注 册:2006-7-23
得分:0 
这可能是版本问题,你的程序可能只能在 1.0下运行。

我刚做的论坛:bbs.,欢迎大家光临!交友QQ:45094574.
2006-09-02 01:18



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




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

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