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);

它会更新除描述列之外的所有列!

4

2 回答 2

0

你应该尝试像 [Description]=@Description 因为描述词应该是 SQL 中的一种特殊关键字。

于 2013-11-18T23:35:35.500 回答
0

首先尝试检查您的代码并对其进行跟踪,然后查看 SQL Profiler 以获取从您的应用程序发送到 sql 的内容。另请注意,Description 是 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;
于 2013-12-11T09:16:00.803 回答