1

我制作了通过加入 2 个表 CustomerInfo 和 Offers 产生的网格 将 Offers.OfferDescription 列作为下拉列表,当涉及到编辑模式时,它转到文本框,当我更新时我得到了那个错误

无法绑定多部分标识符“Offers.OfferDescription”

这是我的选择代码

SELECT CustomerInfo.NationalID, CustomerInfo.FNama, CustomerInfo.LName,      
CustomerInfo.MobileNumber, Offers.OfferDescription 
FROM CustomerInfo INNER JOIN Offers ON CustomerInfo.OfferID = Offers.OfferID 
WHERE (CustomerInfo.UserName = @UserName)

这是我的更新代码

UPDATE      CustomerInfo
SET         PhoneNumber = @PhoneNumber, Offers.OfferDescription = @OfferDescription, FNama = @FNama, LName = @LName, OfferID = @OfferID
FROM        CustomerInfo AS CustomerInfo_1 INNER JOIN Offers ON CustomerInfo_1.OfferID = Offers.OfferID CROSS JOIN CustomerInfo
4

2 回答 2

0

您一次只能对一个表执行 UPDATE 或 INSERT (使用内部连接更新多个表)。在您的更新查询中,您正在尝试更新两个表。请尝试使用以下两个查询进行更新:

UPDATE      CustomerInfo
SET         PhoneNumber = @PhoneNumber,  FNama = @FNama, LName = @LName, OfferID = @OfferID
FROM        CustomerInfo, Offers
WHERE       CustomerInfo.OfferID = Offers.OfferID

UPDATE      Offers
SET         OfferDescription = @OfferDescription
FROM        CustomerInfo, Offers
WHERE       CustomerInfo.OfferID = Offers.OfferID

(请确认设置操作中使用的列名)

于 2012-12-28T11:13:01.007 回答
0

您正在尝试在 CustomerInfo 的更新中更新 Offers.OfferDescription ....

UPDATE      CustomerInfo

设置电话号码 = @电话号码,Offers.OfferDescription =

您不能在表 (a) 的更新中更新外部表 (b) 的列。

于 2012-12-28T10:59:25.393 回答