Hi,
im working on a Winform C# program and when i populate Combobox from mysql table, but i added a blank line to the combo throu code or on the table in mysql. and when i click save bottom it tells me that the connection to the database has not been closed i have check and close it on many diferent way and it just wont work, but if i take the blank line it would work with no problem (i need the blank line).
if any body can help me please.
Sorry, here is the code for populating the combobox
private void cargacombocs(string bsc)
{
try
{
MySqlCommand cmd = Form2.conecxionsyscon.CreateCommand();
MySqlDataReader Reader;
cmd.CommandText = "SELECT subcatp FROM budcatpaf WHERE indpp = '" + bsc + "'";
Form2.conecxionsyscon.Open();
Reader = cmd.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString();
comboBox2.Items.Add(thisrow);
comboBox3.Items.Add(thisrow);
comboBox8.Items.Add(thisrow);
}
}
catch (MySqlException ex2)
{
MessageBox.Show("Code: " + ex2.Message);
}
Form2.conecxionsyscon.Close();
}
this is save to a table in mysql which after saving opens up a crystal report with some info
but before it opens the crystal i get the error message that the coneccion is still open
This is where i create the conection
MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder();
connBuilder.Add("DataBase", srv[1]);
connBuilder.Add("Data Source", srv[0]);
connBuilder.Add("User Id", srv[2]);
connBuilder.Add("Password", srv[3]);
conecxionsyscon = new MySqlConnection(connBuilder.ConnectionString);
MySqlCommand cmd = conecxionsyscon.CreateCommand();