Dawood Abbas

Dawood Abbas

  • NA
  • 264
  • 95.3k

How to get two variable values loop wise in c#?

Jun 11 2015 2:34 AM
I want to insert two variables foreach loop wise into database.how to do it?
 
foreach (string item in split)
{
val = item;
foreach (string uid in useid)
{
useval = uid;
}
command = new SqlCommand();
command.CommandText = "Insert_SentSMS";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@sentTime", sentTime);
command.Parameters.AddWithValue("@mobileNo", val);
command.Parameters.AddWithValue("@userid", useval);
command.Parameters.AddWithValue("@smsType", "Manual");
command.Parameters.AddWithValue("@smsText", smsText);
command.Parameters.AddWithValue("@registrationId", lblCustomSMSRegId.Text);
command.Connection = connection;
command.ExecuteNonQuery();
}
}
 
 
i tried like above but 'useval ' value getting same not other values..
 

Answers (5)