private void button8_Click(object sender, EventArgs e) { string first = "Data Source=" + comboBox3.Text + ";"; if (comboBox1.Text == "Да") { first = first + "AttachDbFilename=" + textBox2.Text + ";"; if (comboBox2.Text != "Аутентификация Windows") { first = first + "Integrated Security=false;"; first = first + "User ID=" + textBox4.Text + ";"; first = first + "Password="******";"; } else { first = first + "Integrated Security=true;"; } first += "Connect Timeout=30;User Instance=True;"; } else { first = first + "Database=" + comboBox4.Text + ";"; if (comboBox2.Text != "Аутентификация Windows") { first = first + "Integrated Security=false;"; first = first + "User ID=" + textBox4.Text + ";"; first = first + "Password="******";"; } else { first = first + "Integrated Security=true;"; } } Connect_to_sql conn = new Connect_to_sql(); try { conn.RunSQLScript(first); } catch (Exception ex) { MessageBox.Show(ex.Message); } }