2012-10-30 18 views
5

我在我的.xsd文件,如下更新查詢:更新查詢適用於所有列,除了一個

UPDATE Factors 
SET CodeFactor = @CodeFactor, Date = @Date, MobileNumber = @MobileNumber, 
     Description= @Description, TotalPrice = @TotalPrice, 
     ShouldPayPrice = @ShouldPayPrice 
     WHERE ID = @Original_ID; 
SELECT ID, CodeFactor, Date, PersonName, MobileNumber, Description, TotalPrice, 
     ShouldPayPrice, PaidPrice, Settlement, Kind 
FROM  Factors 
WHERE ID = @Original_ID 
ORDER BY Date DESC; 

我用它在我的形式之一如下:

Fact.UpdateQuery(txtShomareFactor.Text.Trim(), fdpDate.Text.Trim(), 
       txtMobile.Text.Trim(), txtSharheKharid.Text, 
       Convert.ToInt64(txtJameKol.Text.Replace(",", "").Trim()), 
       Convert.ToInt64(txtMablagheGhabelePardakht.Text.Replace(",", "").Trim()), 
       IDFactorTOShowDetails); 

它會更新除說明列以外的所有列!

+0

IN []像[移動電話號碼] = @MobileNumber – 1Mayur

+0

我做到了,但它並沒有再工作TRY封育字段名。 :(任何其他建議? –

+0

更新時'@ description'有一些值嗎?嘗試調試。它是描述列的有效值嗎? – nawfal

回答

0

您應該嘗試像[Description] = @說明自描述字應該是SQL中的一種特殊關鍵字。

0

首先嚐試檢查您的代碼並對其進行跟蹤,並查看SQL Profiler以獲取應用程序發送給sql的內容。 還注意說明是sql server中的關鍵字。在[]之間使用它或在列名之前使用表名。 像Factors.[Description] 總體呈縮小查詢如下:

UPDATE Factors 
SET CodeFactor = @CodeFactor, [Date] = @Date, MobileNumber = @MobileNumber, 
     [Description]= @Description, TotalPrice = @TotalPrice, 
     ShouldPayPrice = @ShouldPayPrice 
     WHERE ID = @Original_ID; 
SELECT ID, CodeFactor, [Date], PersonName, MobileNumber, [Description], TotalPrice, 
     ShouldPayPrice, PaidPrice, Settlement, Kind 
FROM  Factors 
WHERE ID = @Original_ID 
ORDER BY [Date] DESC; 
相關問題