How to pass this query as string?

I’ve this query:

rs = DB.SelectSQL(“SELECT * FROM cNotifiche WHERE cNotifiche MATCH ?”, txt5Cerca.text)

If i want to pass as String

Dim sql as String
sql = ““SELECT * FROM cNotifiche WHERE cNotifiche MATCH ?”, txt5Cerca.text”

Not works …

Try:

Var sql as String
sql = "SELECT * FROM cNotifiche WHERE cNotifiche MATCH ?"
rs  = DB.SelectSQL (sql, txt5Cerca.text)

Gives me this error:

You need:

Var rs as rowset

2 Likes

It’s strange but whilt on SelectSegmentIndex 0, 1 and 2 all data are correctly shown in report, when SelectSegment is on 3 with the query modified as suggested only numbers of the table are passed the other one fields are all ‘zero’ 0 instead of string.
Any hints ?

Var sql as String
Var rows As RowSet

If SBMostra.SelectedSegmentIndex = 0 then
sql = “SELECT * FROM Notifiche”
rows = DB.SelectSQL (sql)
End If

If SBMostra.SelectedSegmentIndex = 1 then
sql = “SELECT * FROM Notifiche WHERE Notificato = ‘NO’ ;”
rows = DB.SelectSQL (sql)
End If

If SBMostra.SelectedSegmentIndex = 2 then
sql = “SELECT * FROM Notifiche WHERE Notificato = ‘SI’ ;”
rows = DB.SelectSQL (sql)
End If

If SBMostra.SelectedSegmentIndex = 3 then

If rbParolaEsattaSI.value = true then
sql = “SELECT * FROM cNotifiche WHERE cNotifiche MATCH ?”
rows = DB.SelectSQL (sql, txt5Cerca.text)
End If

If rbParolaEsattaNO.value = true then
sql = “SELECT * FROM cNotifiche WHERE cNotifiche MATCH ?”
rows = DB.SelectSQL (sql, txt5Cerca.text + “*”)
End If

End If

Dim rpt As New repArchivio
Dim ps As New PrinterSetup
dim info as new NSPrintInfoMBS(ps.SetupString)
dim printers() as string = NSPrinterMBS.printerNames
dim printer as NSPrinterMBS = NSPrinterMBS.printerWithName(“SHARP”)
info.printer = printer
ps.SetupString = info.SetupString
Dim g As Graphics
g = ps.ShowPrinterDialog
If g <> Nil Then
If rpt.Run(rows, ps) Then
rpt.Document.Print(g)
End If
End If

Your second SELECT when segmentindex=3 overwrites rows.

Why if it’s associated in another if … then ?

If rbParolaEsattaNO.value = true then

Anyway i’ve tried deleting at all the second query in the SelectedSegmentIndex = 3 but the issue is still there …
It’s odd because with the same 2 queries i add data in a listbox and all works properly.
When try to pass data into Report are passed only fields numbers and the other (string) fields are passed as 0.

If rbParolaEsattaSI.value is true, and rbParolaEsattaNO.value is also true, then the rows from the first SELECT are overwritten by the second SELECT.

rbParolaEsattaSI and rbParolaEsattaNO are 2 RadioButtons and there isn’t the possibility that are both true. Or i’m missing something ? I think the issue should be elsewhere and as said i’ve also tried to totally delete the second SELECT and the reports’ fields aren’t passed properly …

If both buttons are in the same Control then you are right.