cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One SQL where clause

0 Kudos

Dear All Experts/Gurus,

I am a newbie in the development of SBO. I would like to ask if what is the proper syntax or practice to be use,

for example i have a textbox or combobox and i will used it's value into my SQL Where clause.

            String ocGroupCodeSelectedItem;
            ocGroupCodeSelectedItem = cGroupCode.SelectedItem.ToString();
            Double oGroupCode;

            SAPbobsCOM.Recordset oRecD = default(SAPbobsCOM.Recordset);
            oRecD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            String sSql11 = "SELECT GroupCode FROM OCRG WHERE GroupCode = ";


            oRecD.DoQuery(sSql11);

            oGroupCode = oRecD.Fields.Item("GroupCode").Value;
            MessageBox.Show(" " + oGroupCode);

Good Day!

Accepted Solutions (0)

Answers (1)

Answers (1)

Johan_H
Active Contributor

Hi Ryan,

Unfortunately the SDK's code base is quite old, and does not have proper parameter management. To pass the value in a textbox to the query, you will have to do so directly into the query. So something like this:

"SELECT GroupCode FROM OCRG WHERE GroupCode = '" + oGroupCode + "' "

You could try and write your own parameter validation method, to prevent sql injection.

Regards,

Johan

0 Kudos

Thanks sir