Hi,
I wrote a custom code like this....
Public Shared Function GETSQL(ByVal month as Date, ByVal year as Date, ByVal partyCode as Integer)
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim sql4 As String
If (IsNothing(partyCode)) Then
sql1 = " select " & vbCrLf
sql3 = " where " & vbCrLf
sql3 = sql3 & " Month(SaleHDR.Date)=month " & vbCrLf
sql3 = sql3 & " and year(SaleHDR.Date)=year " & vbCrLf
sql4 = " GROUP BY Month(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " YEAR(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " DAY(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " ProductGroup.ProductGroupCode " & vbCrLf
Else
sql1 = " select " & vbCrLf
sql3 = " where " & vbCrLf
sql3 = sql3 & " Month(SaleHDR.Date)=month " & vbCrLf
sql3 = sql3 & " and year(SaleHDR.Date)=year " & vbCrLf
sql3 = sql3 & " and Party.PartyCode=partyCode " & vbCrLf
sql4 = " GROUP BY Month(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " YEAR(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " DAY(SaleHDR.Date), " & vbCrLf
sql4 = sql4 & " ProductGroup.ProductGroupCode " & vbCrLf
End If
sql2 = " Month(SaleHDR.Date) as Month, " & vbCrLf
sql2 = sql2 & " YEAR(SaleHDR.Date)as Year, " & vbCrLf
sql2 = sql2 & " DAY(SaleHDR.Date) as Day, " & vbCrLf
sql2 = sql2 & " ProductGroup.ProductGroupCode, " & vbCrLf
sql2 = sql2 & " SUM(ISNULL(SaleDTL.ProductRate,0)*isnull(SaleDTL.ProductQuantity,0)) as SalesAmount " & vbCrLf
sql2 = sql2 & " from " & vbCrLf
sql2 = sql2 & " SaleDTL " & vbCrLf
sql2 = sql2 & " inner Join " & vbCrLf
sql2 = sql2 & " SaleHDR " & vbCrLf
sql2 = sql2 & " ON SaleDTL.Id = SaleHDR.id " & vbCrLf
sql2 = sql2 & " inner Join " & vbCrLf
sql2 = sql2 & " ProductMaster " & vbCrLf
sql2 = sql2 & " ON SaleDTL.ProductId = ProductMaster.ProductID " & vbCrLf
sql2 = sql2 & " inner Join" & vbCrLf
sql2 = sql2 & " ProductGroup " & vbCrLf
sql2 = sql2 & " ON ProductMaster.ProductGroupId = ProductGroup.ProductGroupID " & vbCrLf
sql2 = sql2 & " inner Join " & vbCrLf
sql2 = sql2 & " Party " & vbCrLf
sql2 = sql2 & " ON SaleHDR.PartyId = Party.PartyID " & vbCrLf
GETSQL = sql1 & sql2 & sql3 & sql4
End Function
to use in my project report. I'm just trying to combine two reports(first one without partycode condition, second with a party code condition) into one report by using above custom code.
then i use this as a query expression in a dataset: Code.GETSQL(Parameters!Month.Value,Parameters!Year.Value,Parameters!PartyCode.Value)
but when i try to preview the report i'm getting a error saying:
Cannot set the command text for dataset 'DataSet1'
Error during processing of the command text expression of dataset 'DataSet1'.
Can anyone help me here Please!!!
Very much appreciated if anyone can guide me if there is a other way around.
Thank you!!