火印读后感500字:asp.net和access连接的问题

来源:百度文库 编辑:高校问答 时间:2024/05/09 07:42:21
“/asp.net”应用程序中的服务器错误。
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0246: 找不到类型或命名空间名称“OleDbConnection”(是否缺少 using 指令或程序集引用?)

源错误:

行 10: string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
行 11: strConnection += Server.MapPath("new.mdb"); //*就是数据库的名字
行 12: OleDbConnection objConnection = new OleDbConnection(strConnection);
行 13: OleDbCommand objCommand = new OleDbCommand("select * from hello", objConnection);
行 14: DataSet ds = new DataSet();

源文件: E:\asp.net\insert.aspx 行: 12

注:数据库new.mdb和inset.aspx在同一目录下
其实我使用的是
using System.DATA;
using System.DATA.OLEDB;
源程序
using System.DATA;
using System.DATA.OLEDB;
..............................
<script language="c#" runat="server">

protected void page_load(Object sender, EventArgs e)
{
//建立数据连接
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
strConnection += Server.MapPath("new.mdb"); //*就是数据库的名字
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand = new OleDbCommand("select * from hello", objConnection);
DataSet ds = new DataSet();
objCommand.fill(ds,"hello");
MyDataGrid.DataSource=ds.Tables["hello"].DefaultView;
MyDataGrid.DataBind();
}

</script>

这是部分代码

缺少头文件,在程序前几行加一行这个
using System.data.OleDB;

鍚屾剰

没有倒入命名空间using System.data.OleDB;