If you are using the MySQL database with .Net we can configured a database connection string suing MySqlConnection object. A connection string have
key/value pairs and its separated by semicolons.
Can see Standard MySql server connection string, By default MySql Port number is 3306 if you have changed the port in server need to specify with this.
Server=127.0.0.1;Port=1234;Database=your_database_name;Uid=db_user_name; Pwd=db_user_password;
Sample Code:
<add name="constring" connectionString="Server=localhost; Persist Security Info=True; Database=your_database_name;Uid=db_user_name; Pwd=db_user_password;" providerName="MySql.Data.MySqlClient" />
using (MySqlConnection dbConn = new MySqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString))
{
// Add database code here
}
Comments (0)