I'm using an MS Access database to store data for a desktop application. This week I was asked to give access to the application to some additional users, but whenever they launch the application they are getting the error message:
Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.
I have gone through 5 pages of Google search results trying to find a solution and come up with nothing. Every answer I can find to this problem is either the 2GB limit (which my db is nowhere near) or corruption (which is not the case because only two new users are receiving this error and everyone else is fine).
This is my connection string:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[Path];Jet OLEDB:Database Password=[Password];"
I'm pretty sure this is due to the users' machines missing something, but I cannot figure out what or where they can get it from. Please advise.
Your connection string indicates that you are using the Microsoft.ACE.OLEDB.12.0 driver.
This must be installed on the machine, as it doesn't come with windows.
You can find the driver in the Microsoft Access Database Engine 2010 Redistributable
If the error is Cannot open database . It may not be a database that your application recognizes, or the file may be corrupt, make sure that the Database file (ACCDB/MDB) is not more than 2GB because that's the limit for any Access Database File.
Reference Here
Related
I created a VS setup project in which I added a custom action to create an SQL Server database. I used the code from here https://daoudisamir.com/install-sql-server-database-with-visual-studio-setup/ that is itself a c# adaptation of the Microsoft Docs code here: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/49b92ztk(v=vs.100). I made a little adaptation - the entire connection string is in the code:
string connStr = "Data Source = (localdb)\\MSSQLLocalDB; Initial Catalog = master; Integrated Security=True";
This way, I'm not using any dialogue during the installation and it starts the custom action without any input from the user.
But when trying to the installation file, I get each time a "Failed to connect to server (localdb)\MSSQLLocalDB" error. Some of the times, the inner exception message that I have in the log file said "Login failed for user 'NT AUTHORITY\SYSTEM'", sometimes just "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found".
I know for a fact it's not the code in the custom action - I copied it to a form and added a button for the db creation via the application itself - no problem, no connection problem, db created right away.
I must add, that previously, I had a prerequisite for installing SQL Server Local DB during the application setup. That ended up miserably - it blocked me from having ANY access to the server - I had to uninstall everything VS and reinstall again before it went back to normal.
It seems to me that for some reason, instead of using the default windows user that is running the setup file, for some reason it switches to a different user. Is running the code via an msi file causing this? How can I solve it? It's been 2 full days, I read many threads and didn't find the answer.
Thank you for any help.
Edit: The LocalDB documentation states specifically that
An instance of LocalDB owned by the built-in accounts such as NT
AUTHORITY\SYSTEM can have manageability issues due to windows file
system redirection. Instead use a normal windows account as the owner.
HOWEVER, I didn't choose to run under SYSTEM. For some reason it switches to this user, while after the installation when the application is running with the same connection string, it uses the normal Windows user as expected.
Why is it switching to this user? That's what I'm trying to figure out. I have windows 10 if it matters.
We have 2 legacy systems - One in C++ and other in C# that connect to the same access database. The access database is not password protected and we use the following connection string to connect to the databases
Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False ;Data Source= AlarmHistory.mdb
C# application polls a table in the database every 10 seconds. Once in while , the C# application crashes with the error message -
System.Data.OleDb.OleDbException: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
The log analysis revealed that both the applications are not accessing the database simultaneously ... Any idea on what could cause such a situation... Please Help
They might not be accessing the database at exactly the same time, but that error message indicates that they (or something else) is accessing the lock file at the same time. Is the poll opening and closing the connection each time? You could move the open and close to outside the timer so that the connection is opened and remains open for the life of the application.
I have developed a Desktop Application using Visual Studio 2010 in C# and I am using an Access database file (.accdb) as my backend. The application runs smoothly at my end but when I mail it to my client, the application shows errors everytime it tries to write to the database. I have mailed te database file with the application and the Copy to Output Directory property is set to "Copy if Newer". I am sure the issue is a small one and has something to do with the connectivity or the permissioning of the database file. I need some quick help because I am running out of time. Thanx in advance.
What error is the client getting? Maybe s/he doesn't have write permission to their c:\program files directory.
Does your client have MS-Access or the ACCDB drivers correctly installed? Seems to be a driver issue to me. What is the connection string you are using to open the connection to the access database?
You may also try converting your database to MDB instead of ACCDB. MDB is more widely used, and its drivers are usually pre-installed on all Windows machines. Also, this format doesn't need MS-Access to be installed.
Even though this is not obvious by your error messages Input string is not in the correct format and Operation must be an updatable query, they may indicate that you are using reserved keywords as table or column names.
Have a look at this list (MSDN) and check if you have used any of them in your database.
I have a C# application that uses a localhost DB (MySQL).
Now, when I create the executable I´m assuming that the receptor computer MUST have the exact DB with the the same name and tables, also, must have running WAMP or XAMPP.
If one of this conditions is not accomplished the program will crash horribly, with the errors of Windows/C#.
I could put exceptions for every case, but I´m fearful that I would hide other errors putting exceptions for everything!
With production software, how do you manage this? With exceptions? Writing a manual for the user? etc?
During bootstrapping, I recommend check to see if a DB Connection can be created (in my case, SQL Server), given the database connection string defined in an app.config. Initially, you should do some version checking on the database. If the database can't be found, attempt to create it. if i'ts out of date, attempt to upgrade it. If this process fails, then your database engine instance isn't installed or is unresponsive. For my application case, I exit the program, as there's nothing else to do if the DB can't be accessed.
Once past this point, I generally assume that the DB connection is active.
I have seen this question asked previously but can not find a clear explanation of what is/isn't possible and what workarounds migth be available.
I have an existing C# application that uses SQL CE to store local information. This database is only accessed by a single application and is stored in the user's appdata folder.
Some environments have the appdata folder redirected to a network share which causes SQL CE to throw an exception: "Internal error: Cannot open the shared memory region."
I have read that SQL CE 3.5 SP2 is supposed to allow connections to network shares again, and that SP1 does not, however I have not been able to get it to work. Has anybody had any success getting any version of SQL CE to work over a network share? And if so, what version/code did you use to get it to work?
I have tried using mode=Exclusive in the connection string with no luck.
Or alternatively, has anybody found a different workaround? The data needs to be stored in the user's profile as it is specific per user and should not be accessible by any other user on the system.
I updated the application to use SQL Express with local user instances which worked, but it created too many deployment issues for our customers. I ended up having to write a layer to use Access MDBs while we look at different database options.
My suggestion for writing desktop applications is DO NOT use SQL express or SQL CE for local storage.
I've used SQL CE 3.5 successfully on a networked drive with instances of an application running simultaneously on two networked computers. I was able to update records in the database from both locations.
I'm not sure what would happen if two users accessed the same record at the same time, however this is unlikely in my situation. Just include the database location in the connection string.
Store the data in a folder that is not redirected.
SQL Compact is a single-user, in-process database engine.
Have you tried to put sqlce DB on a shared folder and set its datasource where it is located?
Something like:
"Data Source=\\MySharedfolder\\DB.sdf;Persist Security Info=False;"