I'm pretty new to c# and I'm struggling with this,
I'm trying to make a program that can send "items" to the names I type in the textboxes all at once with SQL stored produce.
I want to while loop textboxes so it changes from textBox1 to textBox2 and so on when it loops. I want to do this cause I have 45 texBoxes and a loop should be good I guess.
this is what I've tried:
int x = 1;
while (x < 46)
{
cmd.CommandText = "EXECUTE usp_GiftItem @sendUser, @SendNickname, @receiver, @itemname, @text, @paymentType, @bOutput";
cmd.Parameters.Clear();
cmd.Parameters.Add("@SendUser", SqlDbType.VarChar).Value = "123";
cmd.Parameters.Add("@SendNickname", SqlDbType.VarChar, 50).Value = textBox89.Text;
cmd.Parameters.Add("@receiver", SqlDbType.VarChar, 50).Value = textbox(x).Text;
cmd.Parameters.Add("@itemname", SqlDbType.VarChar).Value = textBox80.Text;
cmd.Parameters.Add("@text", SqlDbType.VarChar, 1024).Value = textBox88.Text;
cmd.Parameters.Add("@paymentType", SqlDbType.VarChar).Value = "0";
cmd.Parameters.Add("@bOutput", SqlDbType.VarChar).Value = "1";
cn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Item sent", "Success");
cn.Close();
x++;
}
The problem is at @recivers value
I hope you there is a solution to this. Thank you, Much appreciated