I was wondering about something. Lets say I have this piece of code:
if (cbBackup.Checked)
{
log("Making backup, this might take a while..");
SqlCommand comm = new SqlCommand(GetFromResources("databaseInstaller.qry.backup.sql"), conn);
}
SqlCommand comm = new SqlCommand(GetFromResources("databaseInstaller.qry.anotherfile.sql"), conn);
The problem with this is, I cannot make comm again, because it’s already been made. But the code might not reach that part if cbBackup is not checked.
Can I just re-declare the value of comm, even if the program doesn’t get past the IF function? -or should I just make another SqlCommand?
Any other suggestion is welcome, ofcourse.
Edit: It’s not a matter of if-else. One of them always executes, the other one only executes if cbBackup is checked.
1 Answer