MS Access data base reading in c# .exe project - c#

I have created .EXE setup of C# Data Base (MS Access Data Base) Application using this link Create C# Setup. Actually i have only one windows form in my project where i can INSERT and GET the data from MS Access data base.It retrieves data from data base successful, But when i INSERT some data then prompt error message is displayed,that U can only update the Data Base and can't INSERT new data. I don't know what i have done wrong.

Ok, i got my problem. Actually i had installed my project in drive C:\Program File... which i have made Secure, and no deletion or Insertion in a file inside there can occur. So, what i did, is that i reinstall that new software in other Drive, like D:\ and new it is working well.

Related

Where does `dbcontext.savechanges()` save data when no connection string

I am working with Microsoft's documentation and learning c#. I am copying an example of databinding with winforms.
The example works, but where is the data stored? I checked my folder, there is no mdf file, and my computer doesn't have SQL Server installed, but when I added something to the table, close the program and reopen it , the data is still there. Where is the data stored?

If I create a C# desktop application with SQLite, will the database get bundled with the installer?

I am trying to make an application for managing a small store, which will be offline. I am considering using SQLite for my data handling needs. Once I create the installer for this project, does the database get attached to the installer or will have have to take additional steps to make the application work.
Also is SQLite the best way to approach this or should I consider something else?
Since SQLite needs a file to work with you can include a file which contains empty schema of your SQLite database in your setup project and copy it to working directory. Or add your empty db file as a resource to your application. And in your connection string builder/provider check existence of the file if it doesn't exists read it from resource and copy to the target location. And also SQLite is good option for that kind of usage.

Dumping an SQLite database stored as dll file?

A little background first: I need to extract a database from an SQLite dll file for my client who has burned bridges with the previous dev.
I have these 4 files sitting on my desktop:
System.data.SQLite.Linq.dll
System.data.SQLite.dll
SQLite.Interop.dll
Payroll.exe
I am also given the password for the SQLite DB which Payroll.exe uses to interact with the database. With this is it possible for me to dump an SQL file (so I can work with something familiar)?
Major problem is that I have no experience with C#, .NET stuff and DLL files (I know it stands for Dynamic Link Library!)
I'm willing to dabble and learn some C# to do this.
As suggested, I decompiled the source and found some interesting code:
namespace Payroll
{
internal class Payroll_Database
{
private static string ConnectionStr = "Data Source=.\\System.Data.SQLite.Linq.dll; Password=******!";
private static SQLiteConnection Connection = new SQLiteConnection();
It seems certain that System.Data.SQLite.Linq.dll is the database file. I have trouble opening it with tools such as SQLite Browser. I have tried renaming it to a .db, but again no dice.
Your database won't be in the dll and exe files you list.
It should be in a separate file, possibly with an extension like .sqlite, .sqlite3, .sdb3 .db or .db3 (but this is not mandated).
If you can locate the db file, you can open it with any sqlite client (e.g. you can use the firefox sqlite-manager plugin), and extract the data as required.
You could probably find the database filename from the Payroll.exe source code, which you can read by opening Payroll.exe in ILSpy.
If you cannot locate the db file, you will be unable to retrieve the data. In which case, the best you can achieve with the files you list would be to determine the database schema by reading the payroll application's source code.
Update:
Now you've found the connection string, it looks possible that the database could indeed be the System.Data.SQLite.Linq.dll file, and the developer has given it a name to match a known .NET assembly as some kind of security through obscurity.
If that is indeed the db file you should be able to open it directly in a SQLite client application like the firefox sqlite-manager plugin I mentioned above. If you can't open it in a SQLite client application, then you can to check to see if it is a .NET assembly after all by opening it with ILSpy or Microsoft's MSIL disassmebler.
Update 2:
According to this SO question, you should be able to open your encrypted db file with the free SQLite2009 Pro Enterprise Manager.

Release plan for my application on other machine by using .mdf file

I am using SQL server 2008 R2 and VS2010. I made simple application by using this tools. I attach database as .mdf in my application and deploy that application on other machine its works fine. Now if I plan for new release of my app which some extended features, I can upload Code by DLL, But problem is updating .mdf file, to handle this I am exporting database into .xls sheets (Application have one utility to backup database) and then import into SQL Server to create new .mdf file. Someone have better solution on this? Can I open old version of .mdf file in SQL Server(Third party software) and Execute DML/DDL script on it to make latest code and database compatible ? May I keep .sql file in one of my project code and execute it by some utility..? Any Class in C# which can handle this..?
I did not get your query completely. Do you want to upgrade the DB through the application?
You can of course run .sql files through your application, but I'm not sure it would help you change the Database configuration.
Alternatively, if you already have the updated .mdf file and the database name is same, then you can follow the following steps.
1. Detach the database by SSMS in the third party environment through SSMS.
2. Replace the .mdf, .ldf and .ndf (if any) in the disk.
3. Attach the updated .mdf file.
This will get the new Object definitions as well as data.
As far as I'm aware, there is no process for merging .mdf files, because the SQL Server might not be able to identify the similar objects properly as sys tables may be different, and also would not know which data to keep in the final data base, in case the table structure, constraints or data conflicts occur.
However, looking at your requirement, the best way I can suggest is,
1. Generate the Alter scripts for the tables modified (By right clicking on the object name and using Script Table As.. option). Of course, I assume you have the list of objects modified and the modifications.
2. Connect the two DB servers over network and write an SSIS package or Import data from the old DB to the new one for the tables you want.
Hope this helps.

How to restore saved data when uninstalling c# application

For example I have developed c# application (with sql database) and installed on win OS, then use to save some data. Now I need to install new window, what did happen with my saved data?
Generally the data you are referring to might be either created during the installation or when the program itself is used (like an OLTP applicaiton). If lets say you have followed all the best practices and created the application using the created installation package, then the uninstaller should give you the option to either store your preferences like template and layout and such(if your program supprts those kind of things). But as for the data and even more in your case data stored in SQL is not deleted UNLESS you specifically mention in the uninstallation to drop the table or database. So as you are mentioning new window, just ensure the database exists and all the data is in contact(most likely it will be). Then also ensure that the new window is pointing to the data with all the necessary constrings and authentication.

Categories