简体   繁体   中英

VB.NET - This piece of code will run in VS2010 but not in VS2008 - why?

I coded this thing up in VS2010, it worked fine. I needed to port it to VS2008, which went smoothly, aside from fixing how a few lines were worded. But it won't run, and my error codes say it's in opening this database.

com = New OleDbConnection(DB_Path)
com.Open()

With a string at the top defining DB_Path

Public Const DB_Path As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=.\ASPNetDB.mdb"

Those two lines of code at the only thing in a Try statement, so they're the only thing that could be going wrong here. And yes, I made sure to copy the database into the new directory. I even tried using the full direct path in there and that didn't work either.

So what have I missed?

On a 64bit machine in VS2008 you need to set the target CPU to 32bit in the project properties, no 64 bit DLL exist for database access. I hope this helps

只是一个猜测-但您可能必须在VS 2008中使用其他Jet提供程序(而不是4.0),因为它将针对.Net的早期版本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM