I going to check if any of the six numbers into text boxes (that I use for the manual draw) match the numbers stored in the database. This must be done individually for every text box. This means that each text box will be searching in each row (num1, num2, num3, num4, num5, num6). I have one table that has as primary key the name of the person and then I have six columns for each number (name, number1, number2, number3, number4, number5, number6).
At the moment I using an IF statement to check if any numbers match in the database. I do not understand how am I going to tell it to move on to the second text box supposing it finds any number matching. In addition, if that happens it should somehow add those numbers so that it knows whether the numbers that match are six in order to be a winner.
Maybe the IF statement is not the right way to build it, but if I use a loop I do not understand how it is going to work.
I am a beginner and I am not asking you to give me the code, and yes this is an assignment
Here is a small piece of code I wrote:
protected void Button1_Click(object sender, EventArgs e)
{
numbersTableAdapters.lottoTableAdapter num = new numbersTableAdapters.lottoTableAdapter();
numbers.lottoDataTable numtable = num.GetNumbers();
Label1.Text = "";
foreach (DataRow row in numtable.Rows)
if (TextBox1.Text == System.Convert.ToString(row["number1"]) || (TextBox1.Text == System.Convert.ToString(row["number2"]) || (TextBox1.Text == System.Convert.ToString(row["number3"]) || (TextBox1.Text == System.Convert.ToString(row["number4"]) || (TextBox1.Text == System.Convert.ToString(row["number5"]) || (TextBox1.Text == System.Convert.ToString(row["number6"])))))))
{
Label1.Text = " Mr " + System.Convert.ToString(row["name"])
+ ", you have won";
}

New Topic/Question
Reply




MultiQuote





|