我试验一个连接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>