problem in connection with mysql using c#.net RRS feed

  • Question

  • User-207386002 posted

    hi I'm getting problem in the connection with mysql

    I'm developing my first database project using c#.net. it's a desktop apps.
    this is my coding in a class. can anyone please tell me how to open the connection?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using MySql.Data.MySqlClient;

    namespace library_management_system
        class Class1
        public class database1
            public string cnn = "server=;user=root;database=library management system;port=3306;password=password;";
            public string cmd;
            public string da;
            public string dr;      
        public class conn
            database1 x = new database1();
            MySqlConnection cnn1 = new MySqlConnection(cnn1.ConnectionString = x.cnn );
            cnn1 .open();
            MySqlCommand cmd = new MySqlCommand(x.cmd, cnn1);

    Wednesday, May 2, 2012 1:28 PM

All replies

  • User-376918002 posted


    Follow the thread below. It may help you.



    Wednesday, May 2, 2012 1:41 PM
  • User-207386002 posted

    I got your point but I want to reduce the code thats why I want to write in a class and create a object of class and use in every form thats a problem 

    Wednesday, May 2, 2012 2:16 PM