Q:

how to convert odbc connection to sql connection?

Right now I'm using this ODBC connection and it's working :
try
    {
        using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString))
        {
            connection.Open();
            using (OdbcCommand command = new OdbcCommand("SELECT * FROM datas", connection))
            using (OdbcDataReader dr = command.ExecuteReader())
            {
                while (dr.Read())
                {
                        switch (dr["namen"].ToString())
                        {
                            case "gt": Label2.Text = dr["dest"].ToString(); break;
                            case "gp1": Image1.ImageUrl = dr["dest"].ToString(); break;
                            case "gp2": Image2.ImageUrl = dr["dest"].ToString(); break;
                            case "gp3": Image3.ImageUrl = dr["dest"].ToString(); break;
                        }
                }
                dr.Close();
            }
            connection.Close();
        }
    }
    catch (Exception ex)
    {
        Response.Write("An error occured: " + ex.Message);
    }

I want to use SQL Connection so that I can fill datalist into it.
PS: I think if I could use ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString in 
SQLconnection it will solve my problem. 
But I'm not able to think how to do it?

A:

You just need to do a few simple steps.

Download and install the .NET connector for MySQL (you will need to include this when you deploy the program). You may want to install MySQL for Visual Studio on your development machine to add features in to Visual Studio like browsing the database and editing stored procedures.
Include the reference MySql.Data.dll in your project.
Add using MySql.Data; to the top of your file.
Everywhere you see Odbc replace it with MySql.

So your example code becomes 
try
{
    using (MySqlConnection connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString))
    {
        connection.Open();
        using (MySqlCommand command = new MySqlCommand("SELECT * FROM datas", connection))
        using (MySqlDataReader dr = command.ExecuteReader())
        {
            while (dr.Read())
            {
                    switch (dr["namen"].ToString())
                    {
                        case "gt": Label2.Text = dr["dest"].ToString(); break;
                        case "gp1": Image1.ImageUrl = dr["dest"].ToString(); break;
                        case "gp2": Image2.ImageUrl = dr["dest"].ToString(); break;
                        case "gp3": Image3.ImageUrl = dr["dest"].ToString(); break;
                    }
            }
            dr.Close();
        }
        connection.Close();
    }
}
catch (Exception ex)
{
    Response.Write("An error occured: " + ex.Message);
}

You may need to tweak the text in MySQLConnStr to get it to work, see this reference for .NET MySQL connection strings.

