Connect MYSQL From C# coding

Discussion in 'Databases' started by nnimal, Aug 12, 2011.

  1. #1
    Can You pl. explain me to how connect MYSQL by C# coding? what are the class need?
     
    nnimal, Aug 12, 2011 IP
  2. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #2
    You will have to check up the support on this one. But it can be done I mean a lot of applications use both technologies rolled into one.
     
    unknownpray, Aug 13, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Since C# is Microsoft, use the MySQL ODBC connector (download it from the MySQL site) and use an ODBC (ADODB is easy) connection.
     
    Rukbat, Aug 24, 2011 IP
  4. nevenne

    nevenne Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi l want to ask , how to run , c # from sorce code which l havve download fromnet
     
    nevenne, Nov 24, 2011 IP
  5. iliveforyou

    iliveforyou Active Member

    Messages:
    207
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    first you need to download Connector/Net 1.0.10
    i found this on the web:

    private void button1_Click(object sender, System.EventArgs e)
    {
    string MyConString = "SERVER=localhost;" +
    "DATABASE=mydatabase;" +
    "UID=testuser;" +
    "PASSWORD=testpassword;";
    MySqlConnection connection = new MySqlConnection(MyConString);
    MySqlCommand command = connection.CreateCommand();
    MySqlDataReader Reader;
    command.CommandText = "select * from mycustomers";
    connection.Open();
    Reader = command.ExecuteReader();
    while (Reader.Read())
    {
    string thisrow = "";
    for (int i= 0;i<Reader.FieldCount;i++)
    thisrow+=Reader.GetValue(i).ToString() + ",";
    listBox1.Items.Add(thisrow);
    }
    connection.Close();
    }
     
    iliveforyou, Nov 25, 2011 IP
  6. nevenne

    nevenne Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you so uch , thank u again, l will try, l know with php but l have to try with c#
     
    nevenne, Nov 25, 2011 IP