且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

951015 - 如何通过C#连接到数据库?

更新时间:2022-11-30 09:30:11

我不认为发生了因为没有定义用户。据我所知0x8000FFFF是一个灾难性的失败,所以由于某种原因连接无法建立。



我会检查OleDb提供程序是否正确安装并且你能连接吗?使用 OleDbConnection类(系统)从代码到数据库.Data.OleDb) [ ^ ]
I wouldn't think happened because a user isn't defined. As far as I know 0x8000FFFF is a catastrophic failure so for some reason the connection cannot be established.

I would check if the OleDb provider is correctly installed and can you connect to the database from the code using OleDbConnection Class (System.Data.OleDb)[^]


我在这个答案的解决方案中提供了一个课程:



如何使用ASP.NET从WS 2012和IIS 8运行访问 [ ^ ]
I provided a class in my solution to this answer:

How do I run access from a WS 2012 and IIS 8 with ASP.NET[^]


这可能是一个问题有很多原因。

从显而易见的开始:所有用户都可以使用该文件吗?连接向导很可能没有使用您的用户ID来访问该文件,因此如果它所在的文件或teh文件夹没有所有用户所需的访问权限,那么它很容易失败。

之后,检查已安装的数据库引擎类型以连接到Access文件:ACE或JET。 JET是较旧的版本,并且在64位版本中不可用 - 所以如果尝试连接的代码是64位或任何CPU,那么再次连接就会失败。但是...... Visual Studio本身是一个32位应用程序,所以它不能直接使用64位驱动程序 - 所以如果连接测试程序实际上是VS的一部分它可能会失败,因为数据库引擎是64位而且它不能跑吧!



基本上,我们不能告诉你这样做,而且会很好 - 但如果你看起来更加悲伤那些东西,尝试修改现有的数据库连接字符串并在代码中的OleDbConnection对象中使用它:访问连接字符串 - ConnectionStrings.com [ ^ ]可能会有所帮助。
There are quite a few reasons why that may be a problem.
Start with the obvious: is the file available to all users? It's quite possible that the Connection Wizard isn't using your user ID to access the file, so if the file or teh folder it's sitting in doesn't have the required access permissions for all users, then it could easily fail.
After that, check the type of DB engine you have installed to connect to Access files: ACE or JET. JET is the older version, and isn't available in a 64 bit version - so again you could get a failure connecting there if the code trying to connect is 64 bit or "any CPU". But...Visual Studio itself is a 32 bit app, so it can't use 64 bit drivers directly - so if the connection tester is actually part of VS it could be failing because the DB engine is 64 bits and it can't run that!

Basically, we can't tell you "do this, and it'll be good" - but if you get more grief when you've looked that those things, try modifying an existing DB connection string and using it in an OleDbConnection object in your code: Access connection strings - ConnectionStrings.com[^] may well help.

>