Petapocoを使用していくつかの日時フィールドを更新しようとしましたが、更新は常に失敗するため、SQLプロファイラーを検索して次の実行ステートメントを見つけました。
exec sp_executesql N'UPDATE [db_Product] SET [aName] = @0, [aDesc] = @1, [EmpID] = @2, [UPCCode] = @3, [isActive] = @4, [isExpendable] = @5, [ProductCatID] = @6, [ProductSubCatID] = @7, [PromoCatID] = @8,
[Property1Name] = @9, [Property2Name] = @10, [RackPrice] = @11, [DiscountMethod] = @12, [DiscountAmount] = @13, [SellingPrice] = @14, [Cost] = @15, [CurrencyType] = @16, [qtyPerSaleMin] = @17,
[qtyPerSaleMax] = @18, [SupplierID] = @19, [BrandID] = @20, [StartDate] = @21, [EndDate] = @22, [MadeIn] = @23, [TakeStockName] = @24, [LifeCycleName] = @25, [ReOrderQty] = @26, [ReOrderPoint] = @27,
[ReOrderDays] = @28, [PreOrderDays] = @29, [aMemo] = @30, [Updator] = @31, [DateUpdate] = @32 WHERE [ProductID] = @33',N'@0 nvarchar(4000),@1 nvarchar(4000),@2 int,@3 nvarchar(4000),@4 int,@5 int,@6 int,@7
int,@8 int,@9 nvarchar(4000),@10 nvarchar(4000),@11 decimal(4,4),@12 nvarchar(4000),@13 decimal(4,4),@14 decimal(4,4),@15 decimal(4,4),@16 nvarchar(4000),@17 int,@18 int,@19 int,@20 int,@21 datetime,@22
datetime,@23 nvarchar(4000),@24 nvarchar(4000),@25 nvarchar(4000),@26 int,@27 int,@28 int,@29 int,@30 nvarchar(4000),@31 int,@32 datetime,@33
int',@0=N'testxxx',@1=N'',@2=0,@3=N'',@4=0,@5=0,@6=1,@7=0,@8=0,@9=N'Color',@10=N'Size',@11=0,@12=N'%',@13=0,@14=0,@15=0,@16=N'TWD',@17=0,@18=0,@19=0,@20=0,
@21=''2013-01-20 12:28:00:000'',@22=''2063-01-20 12:28:00:000'', <--problem
@23=N'TW ',@24=N'週盤',@25=N'新品',@26=1,@27=1,@28=3,@29=1,@30=N'',@31=0,
@32=''2013-02-04 02:45:47:640'' <----problem
,@33=1
何らかの理由で、すべての日時フィールドに''が含まれているため、更新時にエラーが発生します。
編集:C#コード、BAL
public int Update(int _id, ProductManager _M)
{
int result = _M.Product.UpdateByID(_id, _M.Product);
return result;
}
C#コード、DAL
public virtual int UpdateByID(int _id, db_Product data)
{
data.DateUpdate = DateTime.Now;
using (var db = new ConnClass().ConnDB())
{
var result = db.Update(data, _id);
return result;
}
}
BAL _M.Product.UpdateByID(_id、_M.Product); 更新のためにDALコードに更新を送信します。ProductManager _Mの値を確認しましたが、dateTime値は有効です。
ペタポコ実行コマンド
UPDATE [db_Product] SET [aName] = @0, [aDesc] = @1, [EmpID] = @2, [UPCCode] = @3, [isActive] = @4, [isExpendable] = @5, [ProductCatID] = @6, [ProductSubCatID] = @7,
[PromoCatID] = @8, [Property1Name] = @9, [Property2Name] = @10, [RackPrice] = @11, [DiscountMethod] = @12, [DiscountAmount] = @13, [SellingPrice] = @14, [Cost] = @15, [CurrencyType] = @16, [qtyPerSaleMin] = @17, [qtyPerSaleMax] = @18, [SupplierID] = @19, [BrandID] = @20,
[StartDate] = @21, [EndDate] = @22, [MadeIn] = @23, [TakeStockName] = @24, [LifeCycleName] = @25, [ReOrderQty] = @26, [ReOrderPoint] = @27, [ReOrderDays] = @28, [PreOrderDays] = @29,
[aMemo] = @30, [Updator] = @31, [DateUpdate] = @32 WHERE [ProductID] = @33
私はすでにこの面白い結果をデバッグするのに数日を費やしました...