Hey,
We use a Schema Command to fill the DataSet. Maybe that’s the difference with your example, because we can’t get it to work.
We captured the resulted SELECT in SQL Profiler (You can see the (1=1) at the end, but we definitely use a WhereExpression and a TableRequestInfoV5 with a WhereClause and Parameters):
exec sp_executesql N’SELECT
[art_ID],
Article.[DateCreated],
Article.[DateModified],
Article.[UserIDCreated],
Article.[UserIDModified],
[art_ArticleCode],
[art_CustomerReference],
[art_SupplArtReference],
[art_SupplColorReference],
[art_Description],
[art_MainGroupID],
[art_SubGroupID],
[art_GroupID],
[art_Param1], [art_Param2], [art_Param3], [art_Param4], [art_Param5],
[art_Param6], [art_Param7], [art_Param8], [art_Param9], [art_Param10],
[art_Param11], [art_Param12], [art_Param13], [art_Param14], [art_Param15],
[art_Param16], [art_Param17], [art_Param18], [art_Param19], [art_Param20],
[art_Param21], [art_Param22], [art_Param23], [art_Param24], [art_Param25],
[art_ColorID], [art_SubColorID], [art_SupplierID],
[art_BrandID], [art_SizeBarID], [art_SeasonID],
[art_VATID], [art_LabelType], [art_LabelDescr],
[art_StartSize], [art_StopSize], [art_InventoryTableID],
[art_StockLocationID], [art_LastCommandDate], [art_LastDeliveryDate],
[art_PublishToWeb], [art_CanReorder], [art_PictureName], [art_AnimationName],
[art_ModelDescription],
[art_Comment],
IsNull(vat_Perc,0) as VATPercent,
art_IsActive,
art_AccountingID,
art_Theme1ID,
art_Theme2ID,
art_Design,
Article.WebTrans,
Article.WebDate,
art_IsRent,
art_RentDay,
art_EverPublishedToWeb,
art_PurchasePriceNet,
art_SalePrice1,
art_SalePrice2,
art_SalePrice3,
art_SalePrice4,
art_LocationShop,
art_LocationWareHouse,
art_SupplRef1,
art_SupplRef2,
art_SupplRef3,
art_SupplRef4,
art_SupplRef5,
art_ReductionActive,
art_CostumePrice,
art_WebModel1,
art_WebModel2,
art_WebModel3,
art_WebSubGroup1,
art_WebSubGroup2,
art_WebSubGroup3,
art_WebSite,
art_CanReorderWeb,
art_WebSubGroupType1,
art_WebSubGroupType2,
art_WebSubGroupType3,
– MainGroup
IsNull(MainGroup.arg_Description1,’’’’) as MainGroupDescr1,
IsNull(MainGroup.arg_Description2,’’’’) as MainGroupDescr2,
IsNull(MainGroup.arg_Description3,’’’’) as MainGroupDescr3,
IsNull(MainGroup.arg_Description4,’’’’) as MainGroupDescr4,
-- SubGroup
IsNull(SubGroup.arg_Description1,'''') as SubGroupDescr1,
IsNull(SubGroup.arg_Description2,'''') as SubGroupDescr2,
IsNull(SubGroup.arg_Description3,'''') as SubGroupDescr3,
IsNull(SubGroup.arg_Description4,'''') as SubGroupDescr4,
-- Group
IsNull(ArtGroup.arg_Description1,'''') as GroupDescr1,
IsNull(ArtGroup.arg_Description2,'''') as GroupDescr2,
IsNull(ArtGroup.arg_Description3,'''') as GroupDescr3,
IsNull(ArtGroup.arg_Description4,'''') as GroupDescr4,
-- MainColor
IsNull(MainColor.col_Description1,'''') as ColorDescr1,
IsNull(MainColor.col_Description2,'''') as ColorDescr2,
IsNull(MainColor.col_Description3,'''') as ColorDescr3,
IsNull(MainColor.col_Description4,'''') as ColorDescr4,
-- SubColor
IsNull(SubColor.col_Description1,'''') as SubColorDescr1,
IsNull(SubColor.col_Description2,'''') as SubColorDescr2,
IsNull(SubColor.col_Description3,'''') as SubColorDescr3,
IsNull(SubColor.col_Description4,'''') as SubColorDescr4,
-- Supplier
IsNull(sup_Name,'''') as SupplierName,
-- Brand
IsNull(bra_BrandName,'''') as BrandName,
-- SizeBeamHeader
IsNull(sbh_Description,'''') as SizeBeamHeader,
-- Season
IsNull(sea_Description,'''') as Season,
-- theme 1
IsNull(theme1.tmh_Description1,'''') as Theme1Descr1,
IsNull(theme1.tmh_Description2,'''') as Theme1Descr2,
IsNull(theme1.tmh_Description3,'''') as Theme1Descr3,
IsNull(theme1.tmh_Description4,'''') as Theme1Descr4,
-- theme 2
IsNull(theme2.tmh_Description1,'''') as Theme2Descr1,
IsNull(theme2.tmh_Description2,'''') as Theme2Descr2,
IsNull(theme2.tmh_Description3,'''') as Theme2Descr3,
IsNull(theme2.tmh_Description4,'''') as Theme2Descr4,
ISNULL(Qty, 0) as StockQty,
Isnull(SaleQty,0) as SaleQty,
Isnull(lbl_Description,'''') as LabelDescription,
Isnull(pri_SalePrice,0) as SalePrice,
Isnull(pri_PurchasePrice,0) as PurchasePrice,
Isnull(pri_PurchasePriceOrg,0) as PurchasePriceOrig
FROM
Article
left join ArticleGroup MainGroup on MainGroup.arg_ID = art_MainGroupID
left join ArticleGroup SubGroup on SubGroup.arg_ID = art_SubGroupID
left join ArticleGroup ArtGroup on ArtGroup.arg_ID = art_GroupID
left join Color MainColor on MainColor.col_ID = art_ColorID
left join Color SubColor on SubColor.col_ID = art_SubColorID
Left join ArticlePrice on pri_ArticleID = art_ID and pri_Position = 1
left join Supplier on sup_ID = art_SupplierID
left join Brand on bra_ID = art_BrandID
left join SizeBeamHeader on sbh_ID = art_SizeBarID
left join Season on sea_ID = art_SeasonID
Left Join Labeltype on lbl_ID = art_LabelType
Left join VAT on vat_ID = art_VatID
Left join ArticleTheme theme1 on art_theme1ID = theme1.thm_ID
Left join ArticleTheme theme2 on art_theme2ID = theme2.thm_ID
LEFT JOIN
(
SELECT stk_ArticleID, COUNT(*) AS Qty
FROM Stock
WHERE ((@ShopID = 0 AND stk_ShopID > 0) OR (stk_ShopID = @ShopID))
GROUP BY stk_ArticleID
)stk ON art_ID = stk_ArticleID
LEFT JOIN
(
SELECT sld_ArticleID, COUNT(sld_SaleQty) AS SaleQty
FROM SalesDetail
GROUP BY sld_ArticleID
)sale ON art_ID = sld_ArticleID
WHERE
(1=1)
order by art_ArticleCode desc’,N’@ShopID int’,@ShopID=1