Update multiple rows at once using c#
Hi,I want to update multiple rows with different values at once (avoid multiple calls to db)using c#(just console app)
static void Main(string[] args)
{
String connectionString = "";
int EID = 0;
string EmailAddress = "";
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand("select * from table", connection))
{
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
EID =int.Parse( reader["Rec_ID"].ToString());
EmailAddress = reader["FirstlName"].ToString();
//take this EID and update values where EID = EID
here i want to update each row with different values based on 'EID '
and update whole thing at once instead of updating each row
}
Console.ReadLine();
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
thanks
madhu