MySQL C# - Export database - c#

I'm a beginner so I'll try to explain what I'm trying to do so please bear with me:
I'm developing a db application on C# and I'm using MySQL (Workbench) to manage my database so when I establish the connection in the C# project I use the following connection string:
string MyConnectionString = "Server=localhost;Database=catalogue;Uid=root;Pwd=1234;";
But I'd like to send the project to a friend to check it out so what would be the easiest way to send him the DB as well? Is there a way to send it as a single file (something like an Access db) and modify the connection string so that the project works without him adding the db to the localhost.
Thank you!

Related

Azure mobile EasyTables connection string

I am fairly beginner in here, so any help would be much appreciated :)
So, I created a SQL Database and I want to connect EasyTables to it. Apparently the automatic option has been removed and I have to do it manually.
I followed "How can I add a connection string manually" page but it lead me to nothing.
Where should i create the connection string, and what to put in the value field?
Or if there is any tutorials out there for the new way please tell me :)
Thank you a lot
You said you have followed tutorial: How can I add a connection string manually.
The Easy Table connection should like this:
SQL Database Connection String format
Data Source=tcp:{your_SQLServer},{port};Initial Catalog={your_catalogue};User ID={your_username};Password={your_password}
{your_SQLServer} Name of the server, this can be found in the
overview page for your database and is usually in the form of
“server_name.database.windows.net”.
{port} usually 1433.
{your_catalogue} Name of the database.
{your_username} User name to access your database.
{your_password} Password to access your database.
Add the connection string to your Web App
In App Service, you can manage connection strings for your application by using the Configuration option in the menu.
To add a connection string:
Click on the Application settings tab.
Click on [+] New connection string.
You will need to provide Name, Value and Type for your connection
string.
If your are adding a connection string to a SQL Azure database choose
SQLAzure under type.
If your are adding a connection to an Azure Storage account, chose
Custom under type.
NOTE If you are adding a connection string because you are planning on using the Easy API or Easy Table features, then the connection strings used by this features expect the following specific names:
Azure SQL database: MS_TableConnectionString
Azure Storage account: MS_AzureStorageAccountConnectionString
For example, this is my connection string:
When you have configured this, go to Easy table, click Add to add the table name in your Azure SQL database.
You can find that esay table has connected to my Azure SQL database now and we can see the data in the table.
Update:
You should first add the connection string in the configuration followed the format provided for you.
Then go to Easy Table, configure Easy table API:
Choose the 2:
When it done, you can add table in your SQL database, please follow my steps in above.
Note:
Your connection string name must be: MS_TableConnectionString.
Hope this helps.

How to embed SQLite database files into WPF application

I tried searching the net for this probably simple answer, but without success. I have my WPF app almost ready - using connection strings to connect to my 3 databases (EnteralDB, ParenteralDB, PatientDB) that have several tables.
Problem is that it works while debugging because I hard wired the connection string to specific location (my desktop)
using (SQLiteConnection con = new SQLiteConnection(#"Data Source= C:\Users\Peter\Desktop\EnteralDB"))
But how I can I make the connection string "universal" - meaning that it will work when I create setup for the app and it will install on a new computer? How to embed the database files into the project so they are PART of the project itself and then somehow point with the connection strings to them?
Thank you very much for help!
EDIT Actually, the comment by Clemens is correct. I changed the connection string to just the filename (EnteralDB.db), set copy if newer with content for the database properties and it is working

C# How add mysql connection to separated class?

Is it possible to add MySQL connection to another Class (as public) in C# and call the connection in other classes instant of typing all connection code lines every time and for each part of the program ?
Is it secure and correct to do something like that ?
For EX, in PHP we can use include, is any other way in C# to do the same ?
I know we can use Public classes in C# and call them in other part of program, like using function in PHP, so I would like to know if it's secure to use same method in C# for MySQL connection !
And finally, if someone can explain me how to make it happen (have MySQL connection in separated class) or send me a link where it explain that !
Well, as I learned, it's not a good idea to use MYSQL connection info into the app and so I just created a PHP file on my server and I use webclient post to send and receive data to and from the PHP file and I have my database connection into my PHP file too.
What you are looking for is called data Access layer. I suggest you to look at entity Framework also.

Can not connect to MySQL with VS2012

I am trying to establish connection between my application in C# and MySQL. I have downloaded .NET connector from MySql website.
I have installed MySQL server with TYPO3 winstaller, and it is running properly.
Here is my code:
MySqlConnection con = new MySqlConnection("Server=localhost:8501;Database=drogy;Uid=root;Pwd=;");
con.Open();
It says that: Unable to connect to any of the specified MySQL hosts.
In PHPMyAdmin I see host as localhost:8501. I am sure that user root has password set to NO and I am also pretty sure about the database name. How can I do this please? Thank you
you should not mention the password if maybe its should be empty means use the ' ' single quotes in you code.
And you should remove the ; in after the password like ot;Pwd=;"); you should change like ot;Pwd=");
if your not add the connector, first of all you should must add the MySQL Connector.
sample code:
"server=localhost:portno; user id=yourusername; password=yourpassword; database=yourdatabasename"
update:1
All had happend after moving database files to new location and after updating mysql server. All tables with InnoDB engine disappeared from my database. I was trying to recreate them, but mysql told me 1146: Table 'xxx' doesn't exist all the time until I had recreated my database and restarted mysql service.
I think there's a need to read about InnoDB table binaries.
click here : 1
*Pwd=;"*Required your database password
In the password field give your password and try it.. it will work

Connecting to an external SQL Database using odbc commands and C#

I am trying to write C# code to access a database using odbc commands, the database is not local.
My connection string looks like that:
Driver={SQL Server};Server=serverName;Database=dbname;UID=username;PWD=apassword;
Somehow I cannot get the connection to open....
Can someone explain why? am i missing something in the string?
Try this ODBC connection string:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
as described here

Categories

Resources