'Report_PS.PrintController = New StandardPrintController
![sql server management studio format query sql server management studio format query](https://docs.microsoft.com/en-us/sql/ssms/tutorials/media/ssms-tricks/errorlog.png)
WHERE OrderDate BETWEEN AND cn As New SqlConnection With Public Function GetDatesBetween(pStartDate As Date, pEndDate As Date) As DataTable WHERE OrderDate BETWEEN AND for the above I would write the following method (note there are parts that I have not included but have included enough to see it works) Imports Think of dates between two dates you can useīETWEEN coupled with parameters DECLARE AS DATE= '' Parameters for where you are using sqlDate (which I don't know what that does). In regards to why this does not work in VB.NET and works in SSMS, the one thing that sticks out is the lack of using Since this is VB.NET this is the wrong forum so I'm moving your question to the VB.NET forums. i have tried using parameters still not work for same date When i run in SQL management Studio i got this results Have copied the command using set ttext method and tried that Query in SQL management Studio
![sql server management studio format query sql server management studio format query](https://blog.sqlauthority.com/i/e/darktheme1.jpg)
Public Function SqlDate(d As Date) Dim rd As String rd = Format(d, "yyyy-MMM-dd") Return rd End Function Report_PS.DefaultPageSettings.PaperSize = New PaperSize("Custom", 300, 10000) Report_PS.PrinterSettings.PrinterName = My.Settings.ThermalPrinter Report_PS.PrintController = New StandardPrintController QRY = "Select isnull(c.pgroup,'Nogroup') as grp, isnull(sum((a.qty * c.pprice)),0) as purchase, isnull(sum(a.tot),0) as Sales, isnull(sum(a.tot -(a.qty * c.pprice)),0) as profitįrom invitem A left join invoice B on a.invid = b.slno left join products C on C.UPC = a.barcode where b.invdate = '" & SqlDate(Dfrom) & "' group By c.pgroup "ĭim cmd As SqlCommand = New SqlCommand(QRY, cofunctions.Connection)ĭim rdr As SqlDataReader = cmd.ExecuteReader()
![sql server management studio format query sql server management studio format query](https://s33046.pcdn.co/wp-content/uploads/2017/09/word-image-21c.png)
Public Sub Create_group_summary(DfromV As Date, DtoV As Date)ĪddHandler Report_PS.PrintPage, AddressOf PS_PrintPage I have a SQL query Which Run very Well in SQL Management Studioīut when i use VB query The SQL result in Empty or No rows