.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

how to connect mysql with asp.net

Posted By: Ramesh     Posted Date: December 23, 2008    Points:2   Category :ASP.Net
How to connection MySQL database with ASP.NET. can some one help me to provide the connection string to connect MySQL with ASP.net.

As i can not use SQLConnection class so instead of that what i should used to connect or get Data from MySQL.

Any help Should be appreciated

Author: Akhil Raj       [Moderator]      
Posted Date: December 24, 2008     Points: 5   

hi friend,
For connecting mysql to asp.net you need MySql .net connector. You can freely download from the mysql site.

The connections String:

MySqlConnection con = new MySqlConnection("Data Source=SERVER; uid=USERID; pwd=PASSW
ORD; Database= DATABASE");

Author: Shashi Ray             
Posted Date: December 26, 2008     Points: 5   

try this code:

use in webconfig file.

<add key="Shashi" value="server=localhost;uid=sa;pwd=sa123;database=newdata"/>


and this code use in "aspx.cs"(C# code) file
( using System.Data.SqlClient; )

SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Shashi"]);

Shashi Ray

Shashi Kant Ray
Author: Athira Sreejith             
Posted Date: February 24, 2009     Points: 5   



using MySql.Data.MySqlClient;
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "Server=Server;" +
"Database=Test;" +


Imports MySql.Data.MySqlClient
Dim oMySqlConn As MySqlConnection = New _
oMySqlConn.ConnectionString = "Server=Server;" & _

Author: krishana singh             
Posted Date: October 16, 2010     Points: 5   

using connection string with WebConfigurationManager

string connectionString = WebConfigurationManager.ConnectionStrings["dbflowerconnectionstring"].ConnectionString;
SqlConnection con = new SqlConnection();

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend