Hi every one i am sorry its my mistake i have created the connection already in a separate class and again i have been coded new Mysqlconnection :D that's my mistake any how i sought out the problem
//database connection
MySqlConnection con;
dbconnection dbcon = new dbconnection();
MySqlDataAdapter da;
DataSet ds;
public frmpatient()
{
InitializeComponent();
}
private void frmpatient_Load(object sender, EventArgs e)
{
showdatabase();
}
public void showdatabase() {
con = dbcon.openconnection();
con.Open();
MessageBox.Show("Connection ok");
da = new MySqlDataAdapter("select * from actor",con);
ds = new DataSet();
da.Fill(ds);
dataGridViewpatient.DataSource = ds.Tables[0];
con.Close();
}