Try this code for Open Connection...
public void InsertDatabase()
{
try
{
using (SQLConnection conn=new SQLConnection("connection info"))
{
conn.Open();
conn.CommandText="Insert into database";
conn.ExecuteNonQuery();
}
}
catch(exception ex)
{
messagebox.show(ex.tostring());
}
finally
{
conn.close();
}
}