从ASP.NET连接到Access

时间:2015-01-22 19:35:21

标签: asp.net .net vb.net ms-access

我有一个ASP.NET应用程序(用VB.NET编写),需要连接到Access 2007 DB才能执行一些select语句。我无法连接到Access数据库。

以下是我试用的代码......

Dim MDBConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\resus.accdb;Persist Security Info=false"
Dim cnn As OleDbConnection = New OleDbConnection(MDBConnectionString)
cnn.Open()

我得到的错误如下......

System.Data.OleDb.OleDbException: Unspecified error
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at Resuscitation.ReportGenerator.Generate(Page ThisPage, Boolean blnPerformSelfTest)

我还尝试将我的accdb文件放在App_Data文件夹中,然后使用以下连接字符串...

Dim MDBConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|resus.accdb;"

这给了我同样的错误。

我在Windows窗体应用程序中尝试了代码并且工作正常。

我在这里想到的是在ASP.NET应用程序中使用它?

谢谢!

0 个答案:

没有答案