I'm trying to make an application where I can back up multiple banks at the same time by putting bank information (which will be backed up) within a bank that will allocate this information.
But I can not put the information through a syntax error, could you help me by saying what's wrong with the syntax?
private void cadastroButton_Click(object sender, EventArgs e)
{
try
{
if (dataBaseBox.CheckedItems.Count == 0)
{
MessageBox.Show("Por favor selecione um Banco de Dados.");
return;
}
else
{
foreach (var check in dataBaseBox.CheckedItems)
{
cn = new SqlConnection(connString2());
cn.Open();
string query;
query = "INSERT INTO bancos(nome,diretorio,hora) VALUES = '" + check.ToString() + "','"+horarioBox+"' + '"+locationTextBox.Text + "'";
cmd = new SqlCommand(query,cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
MessageBox.Show("Backup executado com sucesso!");
}