Friday, 15 June 2012

delphi 2007 - error: String and Byte Incompatible -



delphi 2007 - error: String and Byte Incompatible -

while compiling code, produces "incompatible types: 'string' , 'byte'. not see define variable byte.

unitb

function tdatabasemanager.getporttype(portno:string):string; var sqlquery:tsqlquery; begin result := ''; sqlquery := tsqlquery.create(nil); seek sqlquery.sqlconnection := fsqlconnection; sqlquery.sql.clear; sqlquery.sql.text:= 'select '+portno+' tblmk6ecpu_setupindex t1, tblmk6ecpu_setup t2'; sqlquery.sql.text := sqlquery.sql.text + ' t1.batchnumber = '''+batchno+ ''' , t1.mfgcode = t2.mfgcode'; sqlquery.sql.text := sqlquery.sql.text + ' order t1.setupid desc'; sqlquery.active:=true; if (not(sqlquery.isempty())) result := vartostr(sqlquery.fieldvalues[portno]); sqlquery.free; end; end;

unita

for i:= 1 10 begin porttype:=tdatabasemanager.getporttype('port'+i); end;

please advise

in line:

getporttype('port'+i);

you trying append integer straight string literal. not work. need alter instead:

getporttype('port'+inttostr(i));

delphi-2007

No comments:

Post a Comment