private void buttonSend_Click(object sender, EventArgs e)
{
object functionReturnValue = null;
using (System.Net.WebClient client = new System.Net.WebClient())
{
System.Collections.Specialized.NameValueCollection parameter = new System.Collections.Specialized.NameValueCollection();
string url = "My API";
connection.Open();
command = new SqlCommand("Select Column1 From Table1", connection);
datareader = command.ExecuteReader();
while (datareader.Read())
{
string Column = datareader["Column1"].ToString();
parameter.Add("1", Column.ToString());//target numbers
parameter.Add("2", TextBox.Text);//message
parameter.Add("3", "Username");
parameter.Add("passwd", "Password");
dynamic rpb = client.UploadValues(url, "POST", parameter);
functionReturnValue = (new System.Text.UTF8Encoding()).GetString(rpb);
}
datareader.Close();
connection.Close();
MessageBox.Show("Message is sent!.", "Message", MessageBoxButtons.OK);
}
}
I'm working with a SqlDatareader to retrieve data from my column in my database which contains numbers where I want to send my textmessage from a textbox, the problem is that my datareader only reads the first content in the column where I contain my numbers and only sends a single message, instead of sending the messages from the textbox to all the numbers in Column1. Please help.