<%@ Page Language="C#" Debug="true" %>
<html>
<body>
<form runat=server >
<span id="la1" runat=server />
<button id="ss" runat=server >我是科比</button><br>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script laguage="VB" runat="server">
Dim myConnection As OleDbConnection;
Dim myCommand As OleDbCommand;
sub page_load(sender as Object,e as EventArgs) 
dim dbname as string
dbname=server.mappath("asp.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
la1.innertext="Connection Opened!"
end sub
</script>
</form>
</body>
</html>错误提示:Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1002: ; expectedSource Error: Line 8:  <%@ Import NameSpace="System.Data.OleDb" %>
Line 9:  <script laguage="VB" runat="server">
Line 10: Dim myConnection As OleDbConnection;
Line 11: Dim myCommand As OleDbCommand;
Line 12: sub page_load(sender as Object,e as EventArgs) 
 Source File: H:\web\index.aspx    Line: 10 

解决方案 »

  1.   

    是不是数据库路径不对。
    还有楼主的数据库连接不要写在page_load里。
    这样很不好!!!。
    using System;
    using System.Web;
    using System.Data;
    using System.Collections;
    using System.Data.SqlClient;
    namespace _sssxx
    {
    /// <summary>
    /// DataConnection 的摘要说明。
    /// </summary>
    public class DataConnection
    {
    public DataConnection()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    }
    public SqlConnection sqlConn;
    #region 数据库的连接
    public void GetLoadConnection()
    {
    try
    {
    string strConnection = "";
    //从配置文件连接数据库
    strConnection = System.Configuration.ConfigurationSettings.AppSettings["cnndb"];
    sqlConn = new SqlConnection(strConnection.Trim());
    sqlConn.Open(); }
    catch(Exception ex)
    {
    throw new Exception(ex.ToString());
    } }
    #endregion
    #region 退出删除连接,删除数据
    public void Quit()
    {
    try
    {
    sqlConn.Close();
    sqlConn.Dispose();
    }
    catch(Exception ex)
    {
    sqlConn.Close();
    sqlConn.Dispose();
    throw new Exception(ex.ToString());
    }
    }
    #endregion
    #region 执行有返回值的SQL语句
    public DataSet GetQueryData(string strTableName,string strSql)
    {
    DataSet ds = new DataSet();
    try
    {
    GetLoadConnection();
    SqlCommand sqlCommand = new SqlCommand(strSql);
    sqlCommand.Connection = sqlConn;
    sqlCommand.ExecuteNonQuery();
    SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCommand);
    SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(sqlDa);
    if(strTableName == null || strTableName.Trim() == "")
    {
    sqlDa.Fill(ds);
    ds.Tables[0].ExtendedProperties.Add("da",sqlDa);
    }
    else
    {
    sqlDa.Fill(ds,strTableName);
    ds.Tables[strTableName].ExtendedProperties.Add("da",sqlDa);
    }
    }
    catch(Exception ex)
    {
    throw new Exception(ex.ToString());
    }
    finally
    {
    sqlConn.Close();
    sqlConn.Dispose();
    }
    return ds;
    }
    #endregion }
    }
      

  2.   

    我的aspx的文件与access数据库是在同一路径的呀,为什么会显示错误呢!要怎么显示路径呢,请指教Exception Details: System.IO.FileNotFoundException: 找不到指定的模块。Source Error: 
    Line 10: dbname="H:\web\asp.mdb"
    Line 11: myConnection = New OleDbConnection ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname)
    Line 12: myConnection.Open()
    Line 13: la1.text="Connection Opened!"
    Line 14: end sub
     Source File: H:\web\index.aspx    Line: 12