Forum Discussion
AlexKaras
10 years agoChampion Level 3
Hi Vera,
> if I replace the var with one of the barcodes from file, all works. But it doesn't work with the var.
In this case it looks like there is some problem with the value of the var1 variable.
I would recommend to add some variable (e.g. with the strSQL name) and use it to build the SQL string. E.g.:
strSQL := 'select i.tel_number, i.sms_type from sms.sms_item t join sms.sms_info i on t.ID_SMS_ITEM=i.ID_SMS_ITEM where t.BARCODE='+ StrToInt(var1);
RecSet := AConnection.Execute(strSQL);
Put a breakpoint on the RecSet := ... line and examine the value of the strSQL variable. Is it valid? Can the query be executed if you copy the value of the strSQL variable and execute it from the Oracle development tool?
As a side note: your code is pretty ineffective. The problem is that you are creating ADO object, open connection to DB, etc. on each cycle iteration. This is very resource consuming and I would recommend to create the ADO object, open the connection and create an SQL string outside of the data loop. For the cases like yours, it is not recommended to build SQL string like you do, but introduce a parameter for the barcode value (see MSDN and Delphi documentation for more details and code samples). Then, within the loop, you will need just to assign the value to the parameter and execute the query. This is much more reliable and effective.
> if I replace the var with one of the barcodes from file, all works. But it doesn't work with the var.
In this case it looks like there is some problem with the value of the var1 variable.
I would recommend to add some variable (e.g. with the strSQL name) and use it to build the SQL string. E.g.:
strSQL := 'select i.tel_number, i.sms_type from sms.sms_item t join sms.sms_info i on t.ID_SMS_ITEM=i.ID_SMS_ITEM where t.BARCODE='+ StrToInt(var1);
RecSet := AConnection.Execute(strSQL);
Put a breakpoint on the RecSet := ... line and examine the value of the strSQL variable. Is it valid? Can the query be executed if you copy the value of the strSQL variable and execute it from the Oracle development tool?
As a side note: your code is pretty ineffective. The problem is that you are creating ADO object, open connection to DB, etc. on each cycle iteration. This is very resource consuming and I would recommend to create the ADO object, open the connection and create an SQL string outside of the data loop. For the cases like yours, it is not recommended to build SQL string like you do, but introduce a parameter for the barcode value (see MSDN and Delphi documentation for more details and code samples). Then, within the loop, you will need just to assign the value to the parameter and execute the query. This is much more reliable and effective.
Related Content
- 11 months agoIso_Yura
- 3 years agoloricotton
- 11 months agonastester
Recent Discussions
- 2 days agoMW_Didata