I'm new to C# so this is quite a noobie question; how would I reference variable Oint in my SQLCOMMAND method
Error: The name 'Oint' does not exist in the current context
If there are some good docs out there that go into detail on C# referencing, I would love if you could provide links.
Thank you in advance
void OE()
{
String OE = comboBox1.SelectedItem.ToString();
if (O == "Yes")
{
int Oint = 1;
}
else if (O == "No")
{
int Oint = 0;
}
else if (O == "OLO only")
{
int Oint = -1;
}
}
void SQLCOMMAND()
{
try
{
String u_conn_input = textBox1.Text;
String conn_string = @"Server=.\" + @u_conn_input + ";Database=Test1;User Id=Test;Password=Test;Timeout=5;";
SqlConnection con = new SqlConnection(conn_string);
SqlCommand command = new SqlCommand("update test1..coup set oe=" + Oint + "where [Coupon Code]=\'" + textBox2.Text + "\'", con);
con.Open();
command.ExecuteNonQuery();
textBox3.Text = textBox3.Text + "Coupon Updated" + Environment.NewLine;
MessageBox.Show(comboBox1.SelectedItem.ToString());
}
catch (SqlException)
{
textBox3.Text = textBox3.Text + "Coupon Update Failed" + Environment.NewLine;
}
}