简体   繁体   English

VB.NET-此段代码将在VS2010中运行,但不能在VS2008中运行-为什么?

[英]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. 我在VS2010中对此代码进行了编码,效果很好。 I needed to port it to VS2008, which went smoothly, aside from fixing how a few lines were worded. 我需要将其移植到VS2008,该软件运行顺利,除了修复了几行的措辞。 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 在顶部带有定义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. 这两行代码仅是Try语句中的唯一内容,因此它们是唯一可能在此处出错的地方。 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. 在VS2008中的64位计算机上,需要在项目属性中将目标CPU设置为32位,不存在用于数据库访问的64位DLL。 I hope this helps 我希望这有帮助

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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