Is there a way to see a database create by SQLiteAsyncConnection class - c#

I'm using SQLiteAsyncConnection in my project to hold my data locally. I would like to see the data inside its tables like using sql server maybe or some tool like that. I've tried where it was created and to open that .db file with sql server but I didn't managed to find it's location
this is how I create the db
var path = Path.Combine(FileSystem.AppDataDirectory, "AppointmentsDB.db");
db = new SQLiteAsyncConnection(path);
I have tried printing the path or
db.DatabasePath
but it gives me a relative path something like this
/data/data/com.companyname.appointments
and I don't know that it's relative to
Now my question is.. is it possible to open that SQLite database with a "visual" tool like sql server 2019? If now then what would you suggest me to use so I can also see that data from sql server 2019?

You can execute "adb pull" to remove the database file from the emulator and put it on your regular hard drive. Similar to "adb pull /data/data/com.companyname.appointments/databases/xxx.db".
If you want to view directly, you need to root your emulator.

Related

How to connect to a SQL Server instance without knowing the Initial Catalog?

I'm writing a portable program that can be used on other computers as well as mine and It also connects to the SQL Database on that computer.
So the problem is that I don't have the database name of that computer. How can my program connect to that Database without previously knowing the database name?
In other words, I don't have enough information to create a complete ConnectionString.
Connect to SQL Server's master database first.
Then, using this query, you can get data from databases in your database:
SELECT name FROM master.dbo.sysdatabases
Using the site below, you can find the right Connection strings for you :
https://www.connectionstrings.com/
You can use a dot in the connection string to represent.tbe local server.
Create a txt file, rename the extension to UDL. Open the UDL file and put a dot, a full stop:
If you have installed a SQL Instance (ie not the default instance) it will be .\InstanceName
Choose the Database drop down and click Test Connect.
Finally close the URL file and open it with NotePad and you will see the connection string.

How to create a crystal report with Firebird's Database

I am trying to build a desktop application. I need to create a report but I don't know how to do? I am using to use FireBird for my Database. I am using windows 8.1.
Of course I am not forget to googling, but I do not know what is wrong with my steps.
The following are the steps that I have tried to do :
download ODBC Driver from this link and install it.
download Firebird-2.5.5.26952-0_x64_embed.zip and extract it to path C:\Firebird-2.5.5.26952-0_x64_embed
Try to Add ODBC Data Source Administrator like this image
I try to test connection but I get an error Open Database C:\Users\User\Documents\FDB\TEST.GDB failed
Whats wrong with my steps?
I am new in c#.
The field Database have to be in following format:
:
for example:
127.0.0.1:c:\Databases\data.gdb

The database cannot be opened because it is version 839. This server supports version 782 and earlier. A downgrade path is not supported

I made a C# project that contains a local database (Microsoft SQL Database Server) (mdf) in my pc that works totally fine. but whenever i use my laptop to run it, it gives me this error:
The database 'C:(the path)\CALENDER.MDF' cannot be opened because it is version 839. This server supports version 782 and earlier. A downgrade path is not supported.
this error appears every time i try to refresh server explorer. i need it to work in my laptop because i use it to make a class presentation.
After a long researches and tries i figured how to solve this issue. its a bit complicated. i converted the mdf database to and access(mdb) and import data from the mdb to a new mdf database.
these are the steps:
Create an empty access (mdb) database.
using SQL Server 2016 CTP3.0 Import and Export Data: import data from database which is calander.mdf in my case to the new access database (mdb).
now in the destination pc, create a new vs form and add a new empty mdf database.
using Microsoft SQL Server Management Studio ( Databases > right click new database > type database name and click OK.)
Right mouse click on your database name and hover to Tasks and then select the Import Data.
select the data source Microsoft Access (Microsoft Access Database Engine) and browse to the access database and click next.
in Destination select Net Framework Data Provider For SqlServer and type the connection string for the new empty created mdf database. then click next and finish.
Copy the new mdf database To your project file
now you got the new database filled with data and all is left is go to your main project and delete the database and then add new existing item and browse to the new database and log file and clock ok. and the database should work
WORKED WITH ME !!!!!!

Cheat application to connect to different SQL Server database

At work I wrote an application that processes data from a SQL Server database and outputs it in file format.
Now I need to use it at home and since app has hard-coded connection string I've got a problem. I got a copy of database at my company, the original database is inaccesable from the outside of the company.
Connection string format looks like this
Data Source=serverName-01;Initial Catalog=dbName_01;Integrated Security=True;Pooling=False
I've tried to cheat app by editing windows hosts file:
serverName-01 127.0.0.1
But it did not work. Is there a way to make it work without going to work and editing source code ?
Lesson learned hard way - never hard-code connection srings :<
To do this you can use an alias defined in SQL Server Configuration manager. Create an alias for your local instance that has the exact same name as the one in the connection string.
Have a look at the following article for how to do this (it's pretty simple):
Create or Delete a Server Alias for Use by a Client (SQL Server Configuration Manager)

Cannot create database file programmatically (SQL Server 2008 R2 Express)

I'm trying to create a database with LINQ to SQL programmatically.
I tried (following this):
MySQLSvrDb db = new MySQLSvrDb(#"c:\mydb.mdf");
if (!db.DatabaseExists())
{
db.CreateDatabase();
}
But I get a SQLException "A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
However, for unit tests I created a database the following way (making sure I have a empty db for every test):
MySQLSvrDb db = new MySQLSvrDb(#"C:\testdb.mdf");
if (db.DatabaseExists())
{
Console.WriteLine("Deleting old database...");
db.DeleteDatabase();
}
db.CreateDatabase();
This works fine. My problem is I don't see a difference to the first approach. The problem is maybe somehow related to this, but the suggested solutions didn't work.
Any hints?
EDIT
If I just skip the DatabaseExists() step it works, but I need to check, if there's already a Db.
How to: Dynamically Create a Database (LINQ to SQL)
How to create DB in Linq to sql
Did you try deleting the first created DB first? and run the method again?
Why you create Database locally,do you still attached it using sql server?
You can use sql lite or sql server ce DB instead.
Regards!

Categories