I am using a wizard control to make the users go through multiple steps. They start at step 1 but sometimes skip some steps if they answer yes or no (radio buttons). For example, a question at the end of some steps would be: "Is the issue fixed?" and there is a yes or no radio buttons choices. If the answer is yes, take them to the last step to finish. If the answer is no, then they go to the next to step.
My issue is getting the results from all the steps to table test in the database.
string constring = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ClientMonitorDevices"].ConnectionString;
SqlConnection conn = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand();
cmd = conn.CreateCommand();
cmd.CommandText = @"INSERT INTO test (siteid, hotelname, step1, step2)
VALUES (@siteid, @hotelname, @step1, @step2)";
cmd.Parameters.AddWithValue("@siteid", siteid);
cmd.Parameters.AddWithValue("@hotelname", hotelname);
int activeStep = Wizard1.ActiveStepIndex;
switch (activeStep)
{
case 1:
if (step1_yes.Checked)
{
step1 = "Device Can Detect Network with a Signal Strength of 50% or Greater";
Wizard1.ActiveStepIndex = 2;
}
else if (step1_no.Checked)
{
step1 = "Device Cannot Detect Network with a Signal Strength of 50% or Greater";
Wizard1.ActiveStepIndex = 16;
}
else
{
e.Cancel = true;
gen.MessagBox(this.Page, "Please choose Yes or No", "Please choose Yes or No");
}
cmd.Parameters.AddWithValue("@step1", step1);
break;
case 2:
if (step2_unable.Checked)
{
step2 = "Unable to Join Network";
Wizard1.ActiveStepIndex = 3;
}
else if (step2_unidentified.Checked)
{
step2 = "Connect to Unidentified Network";
Wizard1.ActiveStepIndex = 7;
}
else if (step2_internet.Checked)
{
step2 = "Connected (Internet Access)";
Wizard1.ActiveStepIndex = 11;
}
else if (step2_local.Checked)
{
step2 = "Connected Local Only (No Internet Access)";
Wizard1.ActiveStepIndex = 15;
}
else
{
e.Cancel = true;
gen.MessagBox(this.Page, "Please Choose One of the Options", "Please Choose One of the Options");
}
cmd.Parameters.AddWithValue("@step2", step2);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
break;
The error I get is Must declare the scalar variable "@step1". because step1 is out of scope or that's what I think. I tried a stored procedure but that didn't work either.
Another attempt was to use update statement but the issue I ran into is getting the ID column (index) which is indexable and and get incremented by 1 with every insert. If anyone have any ideas then by all means let me know. I have been working on this for about 2 weeks now with no avail.