How to browse or extract an old (.db) file - c#

i have an old (.db) database file and i need to extract the contents of it or to use it with a c# application but i dont know which software to use please help me
check this link that lists the db file types.
http://www.file-extensions.org/search/?searchstring=db&searchtype=2
thank you

Well, checking the link in your question, I could browse through the apps that were related to DB extension. And after a quick analysis, I think dBASE will to what you need.
http://www.file-extensions.org/dbase-file-extensions
It allows you to open, edit, save and convert to another extension that might suits you better.
I guess that MS Access and SQLite can do the same thing dBASE will do for you.

The problem is, that *.db has been used by many programs.
Using any Unixoid system (Linux, BSD, MacOS) you can use the file(1) utility to get the program which probably created that file. Using this information you can then ask for more specific help here.
As an example for my *.db files and the output of file:
/etc/libgda-4.0/sales_test.db: SQLite 3.x database
/home/XXX/.mozilla/firefox/cert8.db: Berkeley DB 1.85 (Hash, version 2, native
/var/cache/man/cs/index.db: GNU dbm 1.x or ndbm database,

Related

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.

Reading local MDB(Access) database using silverlight 5?

I am tring to find someway to read from local MDB file. It is a requirement that user may have their own access database. And my silverlight app would be interacting and performing calculations on that data.
Is there any way I can work with it? I have found that ADO.net doesn't come with Silverlight 5.
All the examples I have seen so far, are assuming that there is Wcf service between silverlight client and database.
I can see two options for you:
1) Using the open file dialog get the user to select the file so you can copy it to the Isolated Storage then work on it and get the user to save the file to disk once you have done.
2) Get the user to install you Silverlight application out of brower, this will give you access to the file system and freedom to read the MDB. http://msdn.microsoft.com/en-us/library/dd550721(VS.96).aspx#special_features_for_outofbrowser_applications
Personally i prefer the second option.
I'm assuming you are using ADO.Net to read the database, so you'll need to ensure that the correct provided is installed.
good luck

How to backup SQL Server database (mdf) programmatically to later import it rowwise?

My aim is to backup a database (.mdf) as one file with my web application project written in C#.
The backup should later on be loaded on a "restore"-page, where the data in the backed-up tables could be appended to the original database row by row.
What would be a good practice to implement this?
I thought of just copying the mdf file, but then I read about attaching and detaching of the database. Furthermore I don't know what to do with the _log.ldf file.
I'm looking forward to your hints. Thank you in advance for your help!
EDIT: I can only use the free SQL Server Express for this, because I want to distribute my program to other people.
Probably, you refer to the Backup and Restore using C# for Sql Server to get a complete idea about writting a code in C#, which has helped me a lot when I was using it.
By the use of Backup class in C#, you can get all the facilities to backup as well as restore.
If you are only interested in appending the data rowwise afterwards, perhaps it is easier to export each table to CSV and import it afterwards (so you have rowwwise control in C#).
If you insist ine one file, just add all the CSV's to a zip.
You can use the FileHelpers library for this (http://www.filehelpers.com/) and you will have it up&running in no time.
Apparently there is a Backup class in the SQL Server Management Objects library.
You might want to check that out first, as it doesn't look overly complicated:
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.backup.aspx
It would require you to have two or three libraries installed on the server you run it on, though they are fairly small - not Windows SDK sized...
pls go through this link on how to backup data and restore using c# and sql server .In addition to you have to add these names spaces
Microsoft.SqlServer.Management.Smo;
Microsoft.SqlServer.Management.Common;

SQL Server 2008 FileStream vs Normal Files

I am creating an application like youtube to store videos and I need some advice.
Should I use SQL Server FileStream to store the video files or should I store them somewhere on the hard disk and record the path as a varchar(MAX) inside SQL Server?
Which is recommended and why?
Do you recommend something else apart from both these? Please feel free to tell me but please tell me why too.
Thank you so much.
The FILESREAM type has the advantage of providing transparent transactions while still storing large files on the file system. The drawback is that it is proprietary and if you decide to change database this solution might be less portable to other databases. So providing an objective answer to this question is impossible IMHO.
I would store them outside, simply because there isn't an immediate and pressing need to store them inside. Also, videos are big, and you might need to run them through some other encoding etc steps, which may or may not like SQL Server. Using basic files also gives you the opportunity to spread that load around any number of file servers, rather than a single SQL Server.
Re the path; don't store the full path - only store some path relative to an external root that you configure in your app. That way, you can relocate all the files and just change a single site setting, rather than having to do a big UPDATE. For example, in the DB I might store foo/bar/20110404_27.mpg, and then later combine that with my site-setting of \\myfileserver\share (using Path.Combine).
I think the better way it store the image in FileSystem and save the image and other information in the Database. More information available in these links
Storing a file in a database as opposed to the file system?
http://www.extremeexperts.com/sql/FAQ/StoreImages.aspx
http://www.databasejournal.com/features/mssql/article.php/3719221/Storing-Images-and-BLOB-files-in-SQL-Server.htm
http://forums.asp.net/p/1620545/4189703.aspx/1?Re+Is+File+System+better+than+Sql+Server+for+video+storage+

Where to store configuration for a simple .NET application?

I'm programming a fairly simple application which I want to cut to just one simple EXE file + some data storage (XML for example).
My question is regarding configuration files. Where to put those files? I saw a few applications that have just an EXE file (uTorrent, Media Player Classic - I can use them without any installation), but they store their config somewhere else. How to achieve this?
How would you approach such situation? Is it better to try to achieve the thing I described above, or simply use a configuration file and data storage in the same directory as the EXE file?
Creating or using a file in the same folder (or in the App_Data) is pretty standard practice.
You use an installer like Inno Setup (free) to create a single exe installer (http://www.jrsoftware.org/isinfo.php)
If you want a DB rather than XML, have a look at SQLite (http://www.sqlite.org/) a file based DB or use an MS Access DB.
I think you want to take a look at Application Settings. This is an API which allows you to save user or application settings using a strongly typed API. Under the hood the settings are stored via XML serialization.
This API works with virtually every type of .Net application including low permission Click Once versions. It does the work of finding the place on disk appropriate for storing the data and completely hides it from you. It also has a nice GUI integration into Visual Studio.
EXE-only programs store their data either in the Windows Registry or in the user's Application Data/AppData folder. Although this may appear cleaner at first, it just hides the ugliness of scattering all your data around. I would suggest just going with a simple XML/INI/text data file that is generated when needed and easy to migrate.
Please see: WPF/C#: Where should I be saving user preferences files?
You could use the app.config file for storing your configuration. For the data, I would sugest something like db4o or SQLite.
Edit
This tutorial can show you how simple is to use db40 to store and retrieve your data.
Do not forget Isolated Storage. It gives you a place to read and write files to without the need for you to specify a location. Sometimes it is the only way sandboxed applications (like Silverlight) can store user or machine specific data locally. See here for an example.
I would store them in the same directory. That just seems easier to me, at least that's the way I always do it.

Categories