Unrecognized database format when opening Access file inside Visual Studio - Why? - c#

I have recently taken a project for a client which involves working with their Microsoft Access database programmatically with C# in Visual Studio 2015/2017.
The database opens in my 64-bit version of Microsoft Access 2010 just fine, and I can use/alter all tables/queries perfectly fine. However, when trying to open this .accdb database in Visual Studio, I am getting the dreaded "Unrecognized database format". Now, I do have the Microsoft Office Access database engine for 2007 and 2010 installed, and I am able to open/work with other databases created in Access.
I believe the database was created in Access 2007, as when I open it up, the title of the window contains "(Access 2007 - 2010)", so I'm not sure if that would cause the error or not?
One interesting thing I found was, because I do not need every table in the database, I copied one by one the tables I need into a new database file and checked if I could open this new Access database in Visual Studio. Out of 6 tables that I needed, the last one I needed caused the file to become "unrecognizable" inside Visual Studio.
Why? I have no idea. The table is just like any other, contains lots of columns which either have text, numbers or dates.
My question is, has anybody had a similar experience with this? Could it be the fact that it was made from Access 2007? Why would copying and pasting to a new database then cause that database to be corrupt?
Thanks a lot.

There's a difference in the formats. The older format (..2007) is MDB and the later ones (2010...) are ACCDB. If you used any features only available in ACCDB, like attachments, you cannot convert back to MDB and neither will ANY current Microsoft tool other than Access open it. Strange but true.
Painful is to exclude those tables or forms that use the new features and then do the conversion.....sigh.....

Related

DLL save data - Visual Studio C#

I am making an app using Visual studio for the windows 8 platform. I need to be able to save some data which includes two strings and an array.
I have been searching online about how to save data, many posts have said that I need to save the data in a DLL. However none of these posts cover how you can do it using C#.
Does anyone know how I can do this in C#? The has to be saved permanently, so when the app is opened up again, I can access and use that data. Or if the machine is restarted, the app can still access its old data.
To create DLLs, you have to set up your Visual Studio
https://msdn.microsoft.com/en-us/library/ms164704.aspx

C# Sql Server Express not Saved Permanently

I am using Visual Studio C# 2008 and SQL Server Express. i got a question
i have the following data on my database
and then, i want to insert a new data
after that, i have to make sure that the entered data is saved on my database
it was there, the data was entered succesfully ! but then, when i take a look at my database table
the entered data was not saved permanently. i need to make the entered data saved permanently. how do i resolve this ?
thanks !
You are using the User Instances = true + AttachDbFileName "feature." When you use this "feature" each application you use will open a different copy of the original MDF file. So your C# app opens one copy, you insert a row, but this is never seen in the copy that is open in SSMS / Visual Studio or wherever else you might review the data.
To fix this, STOP USING THIS "FEATURE".
Create/attach your database to a proper instance of SQL Server, and point to it from your app and SSMS / Visual Studio by referencing the server and the logical database name, not the path to an MDF file.
You'll notice I called this a "feature" - in quotes - multiple times. This is because it is not a feature and has caused countless, countless users before you to become absolutely confused about why their inserts and updates "don't work"...

How do I connect my application to eXist-DB

i've created a c# application that is effectively a workflow system that moves XML documents around folder structures depending on their status, among other things.
What i'd now like to do is use a database to store the XML files instead of local folders, but I still need to be able to query them with Linq / XQuery. I've chosen eXist-DB as my database it is gets some fairly good praise.
My question is, how do I connect to my newly created DB from my C# application. If i choose the 'Connect to a DB' option in Visual Studio i'm presnted with a bunch of SQL server options, but nothing that appears to be of any use to connect to my nice new eXist DB.

C# Excel 2010 Workbook Open error

We recently upgraded from Excel 2007 to Excel 2010, and we have found that existing code started failing.
Exception Message:
Office has detected a problem with this file. To help protect your
computer this file cannot be opened.
We have traced this to the line where we open the file
excelApp.Workbooks.Open
Even when opening the file manually, the Protected View Messagebox comes up.
How can we work arround this using C#.
Have a look at using Application.FileValidation Property (Excel) before your Open statement.
Returns or sets how Excel will validate files before opening them.
Read/write
Files that do not pass validation will be opened in a Protected View
window. If you set the FileValidation property, that setting will
remain in effect for the entire session the application is open.
You can set it to one of the enum values in MsoFileValidationMode Enumeration
msoFileValidationDefault
msoFileValidationSkip
if you set it to msoFileValidationSkip before the Open statement, it should bypass the check.
Something like
excelApp.FileValidation = MsoFileValidationMode.msoFileValidationSkip;
before the open statement.
Late to the game here, but this is a common annoyance: you need to define a 'Trusted Location'.
You're not the only developers encountering this problem when your code tries to open a spreadsheet file, and "Office has detected a problem with this file. To help protect your computer this file cannot be opened." is an extremely unhelpful error message.
Look up the Trusted Location code published by Daniel Pineault on DevHut.net in 2010:
DevHut code example: Trusted Location using VBScript
I'll get downvoted to hellandgone for posting VBA in a C# forum, so I'd better not post my implementation of Daniel's code (yes, I'm a VBA developer, bashing out VBA macros all day, not a real coder working with pointy things and curly braces). If you really want to see the VBA, it's in a reply to another post:
https://stackoverflow.com/questions/2962728/office-trusted-locations/28115700#28115700
I believe the proper salutation is 'Share and Enjoy'.
Do, please, put an acknowledgement of the original author, Daniel Pineault, if you reuse the code: it's been widely published without attribution on 'Expert' sites, and that's rather rude.
We had the same issue. Our SSIS package at SQL server uses Excel.Interop to parse files. One day we installed Office 2010 x64 on new server and for some files started getting error:
Office has detected a problem with this file. To help protect your computer this file cannot be opened.
At the same time, other servers work good. We found distinguish in versions of Excel: 14.04763.1000 doesn't work, but 14.0.7015.1000 works for us. The last version number belong to Office 2010 SP2. Eventually we downloaded SP2 and installed it,as result, the error has gone.

Programmatically Repair SQLite Database

I have a need to try and repair a SQLite database from a .NET program if the database file gets corrupted. I have found several sites such as Fix SQLite and in the FAQ it describes that you can:
Depending how badly your database is corrupted, you may be able to recover some of the data by using the CLI to dump the schema and contents to a file and then recreate.
Does anyone know of a way to repair a SQLite database programmatically in .NET?
You might consider implementing your own strategy for database recovery. You could store backups of the SQLite file and then check that it is OK using:
PRAGMA integrity_check;
If errors are found then you can revert to a backup.
You are overlooking one important word: you can 'recover some data', this is not a repair!
If there is a sitatuation where a corrupted database could be repaired perfectly without user-interaction than it would not be corrupted in the first place and such an repair would have been a standard function of SQLite

Categories

Resources