Recent

Author Topic: SQL Parameter not Found  (Read 3242 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
SQL Parameter not Found
« on: December 26, 2021, 06:52:35 am »
I don't know could be i must be resting and enjoy holy days but i still working, well i don't know
what i did wrong, i create a sql sentence with parameters but send me error parameter not found...
 just at first parameter assign value send me error...

the  code run i other app just copy i made changes ......


Code: Pascal  [Select][+][-]
  1.    TsqlmPL.close;
  2.     TsqlOdbc.close;
  3.     TsqlmPL.SQL.Text:='select * from lnk order by lnkid';
  4.     TsqlmpL.Open;
  5.     TsqlMPL.last;
  6.     TsqlOdbc.SQL.Text:='select * from lnk where lnkid >= :plnkid' ;
  7.     TsqlOdbc.ParamByName('plnkid').AsInteger:= TsqlMPL.FieldByName('lnkid').AsInteger;
  8.     TsqlOdbc.Open ;
  9.     if( not TsqlOdbc.Eof) then begin
  10.        TsqlOdbc.next;
  11.     end;
  12.  
  13.     tsqlm.SQL.Text:='insert into lnk ( lnkid , lnksuid , LNKMFRPARTNUMBER , LNKMFRPNID, LNKMFRID, LNKPNID , LNKUNID , LNKpnpartnumber, LNKToPNID, LNKUse, LNKLeadtime, LNKChoice, LNKVendorPN, LNKVendorDesc, LNKAtQty, LNKRFQDate, LNKMinIncrement, LNKCurrentCost, LNKSetupCost, LNKRoHS, LNKRoHSDoc, LNKRoHSNote )  ';
  14.     tsqlm.SQL.Text:=tsqlm.SQL.Text+' Values ( :param1 , :param2 , :param3 , :param4 , :param5 , :PLNKPNID , :pLNKUNID , :pLNKpnpartnumber, :pLNKToPNID, :pLNKUse, :pLNKLeadtime, :pLNKChoice, :pLNKVendorPN, :pLNKVendorDesc, :pLNKAtQty, :pLNKRFQDate, :pLNKMinIncrement, :PLNKCurrentCost, :pLNKSetupCost, :pLNKRoHS, :pLNKRoHSDoc, :PLNKRoHSNote )';
  15.  
  16.     while( not TsqlOdbc.EOF) do begin
  17.  
  18.       tsqlmPN.SQL.Text:='select * from pn where pnid=:ppnid';
  19.       tsqlmPN.ParamByName('ppnid').AsInteger:=TsqlOdbc.FieldByName('LnkPnId').AsInteger;
  20.       tsqlmPN.open;
  21.  
  22. //      showmessage(tsqlm.SQL.Text);
  23.       tsqlm.ParamByName(':param1').AsInteger:= TsqlOdbc.FieldByName('lnkid').AsInteger;
  24. //      tsqlm.ParamByName(':pLnkid').AsInteger   := TsqlOdbc.FieldByName('lnkid').AsInteger;
  25.       tsqlm.ParamByName(':param2').AsInteger := TsqlOdbc.FieldByName('lnksuid').AsInteger;
  26.       tsqlm.ParamByName(':param3').AsString:= TsqlOdbc.FieldByName('LNKMFRPARTNUMBER').AsString;
  27.       tsqlm.ParamByName(':param4').AsString:= TsqlOdbc.FieldByName('LNKMFRPNID').AsString;
  28.       tsqlm.ParamByName(':param5').AsInteger:= TsqlOdbc.FieldByName('LNKMFRID').AsInteger;
  29.       tsqlm.ParamByName(':pLNKPNID').AsInteger:= TsqlOdbc.FieldByName('LNKPNID').AsInteger;
  30.       tsqlm.ParamByName(':pLNKUNID').AsInteger:= TsqlOdbc.FieldByName('LNKUNID').AsInteger;
  31.       tsqlm.ParamByName(':pLNKpnpartnumber').AsString:= TsqlMPN.FieldByName('pnpartnumber').AsString;
  32.       tsqlm.ParamByName(':pLNKToPNID').AsInteger:= TsqlOdbc.FieldByName('LNKToPNID').AsInteger;
  33.       tsqlm.ParamByName(':pLNKUse').AsInteger:= TsqlOdbc.FieldByName('LNKUse').AsInteger;
  34.       tsqlm.ParamByName(':pLNKLeadtime').AsString:= TsqlOdbc.FieldByName('LNKLeadtime').AsString;
  35.       tsqlm.ParamByName(':pLNKChoice').AsInteger:= TsqlOdbc.FieldByName('LNKChoice').AsInteger;
  36.       tsqlm.ParamByName(':pLNKChoice').AsString:= TsqlOdbc.FieldByName('LNKChoice').AsString;
  37.       tsqlm.ParamByName(':pLNKVendorDesc').AsString:= TsqlOdbc.FieldByName('LNKVendorDesc').AsString;
  38.       tsqlm.ParamByName(':pLNKAtQty').AsFloat:= TsqlOdbc.FieldByName('LNKAtQty').AsFloat;
  39.       tsqlm.ParamByName(':pLNKRFQDate').AsString:= TsqlOdbc.FieldByName('LNKRFQDate').AsString;
  40.       tsqlm.ParamByName(':pLNKMinIncrement').AsFloat:= TsqlOdbc.FieldByName('LNKMinIncrement').AsFloat;
  41.       tsqlm.ParamByName(':pLNKCurrentCost').AsFloat:= TsqlOdbc.FieldByName('LNKCurrentCost').AsFloat;
  42.       tsqlm.ParamByName(':pLNKSetupCost').AsFloat:= TsqlOdbc.FieldByName('LNKSetupCost').AsFloat;
  43.       tsqlm.ParamByName(':pLNKRoHS').AsInteger:= TsqlOdbc.FieldByName('LNKRoHS').AsInteger;
  44.       tsqlm.ParamByName(':pLNKRoHSDoc').AsString:= TsqlOdbc.FieldByName('LNKRoHSDoc').AsString;
  45.       tsqlm.ParamByName(':pLNKRoHSNote').AsString:= TsqlOdbc.FieldByName('LNKRoHSNote').AsString;
  46.  
  47.       tsqlm.ExecSQL;
  48.       tsqlmc.close;
  49.       tsqlmpn.close;
  50.       TsqlOdbc.next;
  51.  
  52.     end;
  53.  
  54.     TsqlmPL.close;
  55.     TsqlOdbc.close;
  56.     TsqlmPL.SQL.Text:='select * from su order by suid';
  57.     TsqlmpL.Open;
  58.     TsqlMPL.last;
  59.     TsqlOdbc.SQL.Text:='select * from su where suid >= :psuid' ;
  60.     TsqlOdbc.ParamByName('psuid').AsInteger:= TsqlMPL.FieldByName('suid').AsInteger;
  61.     TsqlOdbc.Open ;
  62.     if( not TsqlOdbc.Eof) then begin
  63.        TsqlOdbc.next;
  64.     end;
  65.     while( not TsqlOdbc.EOF) do begin
  66.        tsqlmpl.SQL.Text:='insert into su ( suid, SUSupplier, SUAddress , SUCountry, SUPhone1, SUPhone2, SUFAX, SUWeb, SUContact1, SUContact2, SUDateLast , SUFollowup, SUNotes, SUCode, SUAccount, SUTerms , SUFedTaxID, SUStateTaxID, SUEMail1 , SUEMail2, SUCURID, SUCurDedExRate, SUCurExRate , SUCurReverse, SUNoPhonePrefix )';
  67.        tsqlmpl.SQL.Text:=tsqlmpl.SQL.Text+'values( :psuid, :pSUSupplier, :pSUAddress , :pSUCountry, :pSUPhone1, :pSUPhone2, :pSUFAX, :pSUWeb, :pSUContact1, :pSUContact2, :pSUDateLast , :pSUFollowup, :pSUNotes, :pSUCode, :pSUAccount, :pSUTerms ,:PSUFedTaxID, :pSUStateTaxID, :pSUEMail1 , :pSUEMail2, :pSUCURID, :PSUCurDedExRate, :pSUCurExRate , :pSUCurReverse, :PSUNoPhonePrefix ) ';
  68.        tsqlmpl.ParamByName('psuid').AsInteger:= tsqlodbc.FieldByName('suid').AsInteger;
  69.        tsqlmpl.ParamByName('psusupplier').AsString:= tsqlodbc.FieldByName('susupplier').AsString;
  70.        tsqlmpl.ParamByName('pSUAddress').AsString:= tsqlodbc.FieldByName('SUAddress').AsString;
  71.        tsqlmpl.ParamByName('pSUCountry').AsString:= tsqlodbc.FieldByName('SUCountry').AsString;
  72.        tsqlmpl.ParamByName('pSUPhone1').AsString:= tsqlodbc.FieldByName('SUPhone1').AsString;
  73.        tsqlmpl.ParamByName('pSUPhone2').AsString:= tsqlodbc.FieldByName('SUPhone2').AsString;
  74.        tsqlmpl.ParamByName('pSUFax').AsString:= tsqlodbc.FieldByName('SUFax').AsString;
  75.        tsqlmpl.ParamByName('pSUweb').AsString:= tsqlodbc.FieldByName('SUweb').AsString;
  76.        tsqlmpl.ParamByName('pSUContact1').AsString:= tsqlodbc.FieldByName('SUContact1').AsString;
  77.        tsqlmpl.ParamByName('pSUContact2').AsString:= tsqlodbc.FieldByName('SUContact2').AsString;
  78.        tsqlmpl.ParamByName('pSUDateLast').AsString:= FormatDateTime('yyyy-mm-dd',tsqlodbc.FieldByName('SUDateLast').AsDateTime);
  79.        tsqlmpl.ParamByName('pSUFollowup').AsBoolean:= tsqlodbc.FieldByName('SUFollowup').AsBoolean;
  80.        tsqlmpl.ParamByName('pSUNotes').AsString:= tsqlodbc.FieldByName('SUNotes').AsString;
  81.        tsqlmpl.ParamByName('pSUcode').AsString:= tsqlodbc.FieldByName('SUCode').AsString;
  82.        tsqlmpl.ParamByName('pSUAccount').AsString:= tsqlodbc.FieldByName('SUACcount').AsString;
  83.        tsqlmpl.ParamByName('pSUTerms').AsString:= tsqlodbc.FieldByName('SUTerms').AsString;
  84.        tsqlmpl.ParamByName('pSUFedTaxID').AsString:= tsqlodbc.FieldByName('SUFedTaxID').AsString;
  85.        tsqlmpl.ParamByName('pSUStateTaxID').AsString:= tsqlodbc.FieldByName('SUStateTaxID').AsString;
  86.        tsqlmpl.ParamByName('pSUEMail1').AsString:= tsqlodbc.FieldByName('SUEMail1').AsString;
  87.        tsqlmpl.ParamByName('pSUEMail2').AsString:= tsqlodbc.FieldByName('SUEMail2').AsString;
  88.        tsqlmpl.ParamByName('pSUCURID').AsInteger:= tsqlodbc.FieldByName('SUCURID').AsInteger;
  89.        tsqlmpl.ParamByName('pSUCurDedExRate').AsBoolean:= tsqlodbc.FieldByName('SUCurDedExRate').AsBoolean;
  90.        tsqlmpl.ParamByName('pSUCurExRate').AsFloat:= tsqlodbc.FieldByName('SUCurExRate').AsFloat;
  91.        tsqlmpl.ParamByName('pSUCurReverse').AsBoolean:= tsqlodbc.FieldByName('SUCurReverse').AsBoolean;
  92.        tsqlmpl.ParamByName('pSUNoPhonePrefix').AsBoolean:= tsqlodbc.FieldByName('SUNoPhonePrefix').AsBoolean;
  93.  
  94.       tsqlmPL.ExecSQL;
  95.       tsqlmc.close;
  96.       tsqlmpn.close;
  97.       TsqlOdbc.next;
  98.  
  99.     end;
  100.  
  101.  
  102.  
 

dseligo

  • Hero Member
  • *****
  • Posts: 613
Re: SQL Parameter not Found
« Reply #1 on: December 26, 2021, 03:01:38 pm »
When you specify named parameter you don't put colon in front of parameter name, do it like this:
Code: Pascal  [Select][+][-]
  1. tsqlm.ParamByName('param1').AsInteger:= TsqlOdbc.FieldByName('lnkid').AsInteger;

Why do you have ' instead of single quotes?

P.S.: Oh, it's something with the forum.
« Last Edit: December 26, 2021, 03:03:15 pm by dseligo »

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: SQL Parameter not Found
« Reply #2 on: December 26, 2021, 06:25:37 pm »
Ok  thanks for you help well I made changes but send me error

fmain.pas(449,23) Fatal: Syntax error, "identifier" expected but "#" found

on this like
  TsqlmPL.SQL.Text:='select * from lnk order by lnkid';

some unit need

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: SQL Parameter not Found
« Reply #3 on: December 26, 2021, 06:59:29 pm »
Wow i see my big mistake could by i was so tired and  i don't see my error


was correct  why i put semicolon in front of parameter.

  tsqlm.Params.ParamByName('plnksuid').AsInteger := TsqlOdbc.FieldByName('lnksuid').AsInteger; 

is the correct instruction...

thanks for your help and sorry.....

 

TinyPortal © 2005-2018