private void AdapterUpdate(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter dataAdpater = new SqlDataAdapter("SELECT [Emp_ID], [User_Name], [Level], [Email_ID], [User_Full_Name], [Is_Active] FROM [LOGIN]",connection);
dataAdpater.UpdateCommand = new SqlCommand("UPDATE [LOGIN] SET [User_Name] = @User_Name " + "WHERE Emp_ID = @Emp_ID", connection);
dataAdpater.UpdateCommand.Parameters.Add("@User_Name", SqlDbType.NVarChar, 15,"User_Name");
SqlParameter parameter = dataAdpater.UpdateCommand.Parameters.Add("@Emp_ID", SqlDbType.Int);
parameter.SourceColumn = "Emp_ID";
parameter.SourceVersion = DataRowVersion.Original;
DataTable categoryTable = new DataTable();
dataAdpater.Fill(categoryTable);
DataRow categoryRow = categoryTable.Rows[0];
categoryRow["User_Name"] = "sivaji the boss";
dataAdpater.Update(categoryTable);
Console.WriteLine("Rows after update.");
foreach (DataRow row in categoryTable.Rows)
{
{
Console.WriteLine("{0}: {1}", row[0], row[1]);
}
}
}
}