0

ASP.NET MVC プロジェクトに取り組んでいます。これは私のコードです:

orderData_Entities ordertable = new orderData_Entities();
DataTable upCSV = (DataTable)TempData["UploadedCSV"];

if (isHeaderAccepted)
{
   string[] data = null;
   int i = 1;

   foreach (DataRow dr in upCSV.Rows)
   {
       ObjectParameter getemail = new ObjectParameter("email", dr["email"].ToString());
       ObjectParameter getpassword = new ObjectParameter("password", dr["password"].ToString());
       ObjectParameter getMobile = new ObjectParameter("Mobile", dr["Mobile"].ToString());

       var results = ordertable.usp_AppUpdateUserData(idSubAccount,idcategory,  getemail.Value.ToString(), getpassword.Value.ToString(), getMobile.Value.ToString());

       ordertable.SaveChanges();
       i++;
    }
}

return RedirectToAction("Index", "BulkUpload");

ここでは、すべての行をループし、結果をテーブルに更新しています。現在、ここで起こっていることは、電子メール、パスワード、モバイルの 3 つの行がある場合、これら 3 つの行すべてを 1 つずつループしており、デバッグ モードで結果を確認できますが、テーブルを更新している間、最後の行の結果を更新しています。 3 行すべてに。

それで、誰かが私がここでやっている間違いを教えてもらえますか?

更新:私のストアドプロシージャは次のとおりです:

 ALTER PROCEDURE [dbo].[usp_AppUpdateUserData]

 @idSubAccount int = 0,
 @idcategory int = 0,
 @email nvarchar(100) =0, 
 @password nvarchar(50) = 0, 
  @Mobile nvarchar(50) = 0,


 AS
BEGIN

Begin
Update tblCustomer
Set  
email = @email, password = @password, mobileNo = @Mobile, 

 where idSubAccount = @idSubAccount and idCategory = @idcategory


 END
 End

  GO
4

0 に答える 0