문제

I have been searching all day for a solution to this problem, but can not find one that works. Basically, I have been connecting to an Access Database through Visual Studio for some time now (there is a reason why I am using Access Database), but all of the sudden it will not connect. Now, anytime I try to add a database connection I receive "Unspecified Error". I have searched here, read MSDN, reinstalled Visual Studio, but nothing seems to work. If I go to "Database Explorer", change to Access Database, browse for file, and hit "Test Connection"/"OK", I will receive the error. It is not file specific either, it is happening to all.

Any ideas? Really need some help here.

도움이 되었습니까?

해결책

Some thoughts that may help:

  • make sure your project is explicitly targeting x86 code, and not x64 or AnyCPU.
    Access Jet (.mdb) only works under 32bit and if you are using ACE (for the new .accdb database format), you are likely using the 32 bit version of the driver as well.
    You cannot mix 32bit and 64bit code and database drivers, just make sure everything is consistent.

  • you may have suffered a corruption of your installation.
    If you can perform the same steps on another machine and if it works there, then you may need to re-install VS (try re-installing the ACE driver first to see if it solves the issue).

다른 팁

Place a try/catch around your code block where you access the database and check the error details returned.

Try
  'Your code here
Catch ex as exception
  msgbox(ex.Message)
Finally
  'any code you want here like close connections etc
End Try

Once you have a bit more information, post it here because "unspecified error" does not say a lot nor have you posted any code so its difficult to see what could be happening.

I have also just encountered this on my VSB2013 connecting to MS Access 2013.

I also solved it bit I do not fully understand why this works how stable it would

Note - the problem occurs when I cycle through 120 ish records. The process is read next record-process - read next record etc etc. The records are similar and some other database reads are required to process the record. The Unspecified error occurs on record/cycle 79 but the records are quite similar.

In my investigation I found that all 3 of the below work (ie the 120ish cycles occur with no errors) - but clearly the first 2 are for debug only

Solution 1 - WORKS) Insert a msgbox into the loop - message box reports the cycle number and record key that is about to be processed

Solution 2 - WORKS) Replaced the msgbox with a line that appends the same text to rich text box on my form with a Cr/Lf.

Solution 3 - WORKS) Replaced the RTB update with the line Threading.Thread.Sleep(15). Tweaking the number of milliseconds to sleep shows that that 15 and above consistently works in my code. Values of 9 and below consistently fail. Values in between 10 and 14 show inconsistent results.

As far as I can tell the sleep method suspends the loop to allow other events and garbage collection to take place. Is this similar to DoEvents that we used in the days upto VB6.

That is as much as I know. Regards Geoff

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top