* * *

Author Topic: [SOLVED]Parameter 6 is of type unknown, which is not suported yet  (Read 1137 times)

nklppc

  • Newbie
  • Posts: 4
Hi im making a quiz game and i run into this error while trying to insert records about players into database this is the code
Code: Pascal  [Select]
  1. procedure save(kveri:tsqlquery;kon:todbcconnection;tr:tsqltransaction;memo11,memo22,memo33:tmemo);
  2. begin
  3.   kon.connected:=false;
  4.   kon.databasename:='rez';
  5.   kveri.sql.text:='select * from tabela';
  6.   kon.connected:=true;
  7.   kveri.active:=true;
  8.  
  9.   kveri.SQL.text:=('Insert into tabela(broj_igraca,imeigraca1,imeigraca2,imeigraca3,imeigraca4,osvojeno1,osvojeno2,osvojeno3,osvojeno4,ukupnoosvojeno) values(:broj_igraca,:imeigraca1,:imeigraca2,:imeigraca3,:imeigraca4,:osvojeno1,:osvojeno2,:osvojeno3,:osvojeno4,:ukupnoosvojeno)');
  10.   kveri.Params.ParamByName('broj_igraca').AsString := inttostr(igra);
  11.  kveri.Params.ParamByName('imeigraca1').asstring := memo11.lines[0];
  12.  if igra=2 then kveri.Params.ParamByName('imeigraca2').AsString := memo11.lines[1] else kveri.Params.ParamByName('imeigraca2').AsString :='/';
  13.  if igra=3 then kveri.Params.ParamByName('imeigraca3').AsString := memo11.lines[2] else kveri.Params.ParamByName('imeigraca3').AsString :='/';
  14.  if igra=4 then kveri.Params.ParamByName('imeigraca4').AsString := memo11.lines[3] else kveri.Params.ParamByName('imeigraca4').AsString :='/';
  15.  if memo33.lines[0]='da' then kveri.Params.ParamByName('osvojeno1').AsString := memo22.lines[0] else kveri.Params.ParamByName('osvojeno1').AsString :='/';
  16.  if igra=2 then if memo33.lines[1]='da' then kveri.Params.ParamByName('osvojeno2').AsString := memo22.lines[1]  else kveri.Params.ParamByName('osvojeno2').AsString :='/';
  17.  if igra=3 then if memo33.lines[2]='da' then kveri.Params.ParamByName('osvojeno3').AsString := memo22.lines[2]  else kveri.Params.ParamByName('osvojeno3').AsString :='/';
  18.  if igra=4 then if memo33.lines[3]='da' then kveri.Params.ParamByName('osvojeno4').AsString := memo22.lines[3]  else kveri.Params.ParamByName('osvojeno4').AsString :='/';
  19.  kveri.Params.ParamByName('ukupnoosvojeno').AsString := inttostr(ukupno);
  20.  kveri.ExecSQL;
  21.  
  22.  kon.connected:=false;
  23.   kon.databasename:='myodbc';
  24.   kveri.sql.text:='select * from pitanja';
  25.   kon.connected:=true;
  26.   kveri.active:=true;
  27.   end;
i connected the access base via odbcconnection.
« Last Edit: May 17, 2017, 05:09:45 pm by nklppc »

valdir.marcos

  • Sr. Member
  • ****
  • Posts: 265
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #1 on: May 16, 2017, 07:56:08 pm »
Hi im making a quiz game and i run into this error while trying to insert records about players into database this is the code
Code: Pascal  [Select]
  1. procedure save(kveri:tsqlquery;kon:todbcconnection;tr:tsqltransaction;memo11,memo22,memo33:tmemo);
  2. begin
  3.   kon.connected:=false;
  4.   kon.databasename:='rez';
  5.   kveri.sql.text:='select * from tabela';
  6.   kon.connected:=true;
  7.   kveri.active:=true;
  8.  
  9.   kveri.SQL.text:=('Insert into tabela(broj_igraca,imeigraca1,imeigraca2,imeigraca3,imeigraca4,osvojeno1,osvojeno2,osvojeno3,osvojeno4,ukupnoosvojeno) values(:broj_igraca,:imeigraca1,:imeigraca2,:imeigraca3,:imeigraca4,:osvojeno1,:osvojeno2,:osvojeno3,:osvojeno4,:ukupnoosvojeno)');
  10.   kveri.Params.ParamByName('broj_igraca').AsString := inttostr(igra);
  11.  kveri.Params.ParamByName('imeigraca1').asstring := memo11.lines[0];
  12.  if igra=2 then kveri.Params.ParamByName('imeigraca2').AsString := memo11.lines[1] else kveri.Params.ParamByName('imeigraca2').AsString :='/';
  13.  if igra=3 then kveri.Params.ParamByName('imeigraca3').AsString := memo11.lines[2] else kveri.Params.ParamByName('imeigraca3').AsString :='/';
  14.  if igra=4 then kveri.Params.ParamByName('imeigraca4').AsString := memo11.lines[3] else kveri.Params.ParamByName('imeigraca4').AsString :='/';
  15.  if memo33.lines[0]='da' then kveri.Params.ParamByName('osvojeno1').AsString := memo22.lines[0] else kveri.Params.ParamByName('osvojeno1').AsString :='/';
  16.  if igra=2 then if memo33.lines[1]='da' then kveri.Params.ParamByName('osvojeno2').AsString := memo22.lines[1]  else kveri.Params.ParamByName('osvojeno2').AsString :='/';
  17.  if igra=3 then if memo33.lines[2]='da' then kveri.Params.ParamByName('osvojeno3').AsString := memo22.lines[2]  else kveri.Params.ParamByName('osvojeno3').AsString :='/';
  18.  if igra=4 then if memo33.lines[3]='da' then kveri.Params.ParamByName('osvojeno4').AsString := memo22.lines[3]  else kveri.Params.ParamByName('osvojeno4').AsString :='/';
  19.  kveri.Params.ParamByName('ukupnoosvojeno').AsString := inttostr(ukupno);
  20.  kveri.ExecSQL;
  21.  
  22.  kon.connected:=false;
  23.   kon.databasename:='myodbc';
  24.   kveri.sql.text:='select * from pitanja';
  25.   kon.connected:=true;
  26.   kveri.active:=true;
  27.   end;
i connected the access base via odbcconnection.

If you indent your coding, it will be much more easy to understand what your are trying to do.
Try:
Code: Pascal  [Select]
  1. procedure save(kveri: TSQLQuery; kon: TODBCConnection; tr: TSQLTransaction;
  2.     memo11, memo22, memo33: TMemo);
  3. begin
  4.   kon.Connected := False;
  5.   kon.Databasename := 'rez';
  6.   kveri.SQL.Text := 'select * from tabela';
  7.   kon.Connected := True;
  8.   kveri.Active := True;
  9.  
  10.   kveri.SQL.Text := 'Insert into tabela( broj_igraca,  imeigraca1,  imeigraca2,  imeigraca3,  imeigraca4,  osvojeno1,  osvojeno2,  osvojeno3,  osvojeno4,  ukupnoosvojeno) ' +
  11.                                 'values(:broj_igraca, :imeigraca1, :imeigraca2, :imeigraca3, :imeigraca4, :osvojeno1, :osvojeno2, :osvojeno3, :osvojeno4, :ukupnoosvojeno)';
  12.  
  13.   kveri.ParamByName('broj_igraca').AsString := inttostr(igra);
  14.   kveri.ParamByName('imeigraca1').AsString := memo11.lines[0];
  15.  
  16.   if igra = 2 then
  17.     kveri.ParamByName('imeigraca2').AsString := memo11.lines[1]
  18.   else
  19.     kveri.ParamByName('imeigraca2').AsString := '/';
  20.  
  21.   if igra = 3 then
  22.     kveri.ParamByName('imeigraca3').AsString := memo11.lines[2]
  23.   else
  24.     kveri.ParamByName('imeigraca3').AsString :='/';
  25.  
  26.   if igra = 4 then
  27.     kveri.ParamByName('imeigraca4').AsString := memo11.lines[3]
  28.   else
  29.     kveri.ParamByName('imeigraca4').AsString := '/';
  30.  
  31.   if memo33.lines[0] = 'da' then
  32.     kveri.ParamByName('osvojeno1').AsString := memo22.lines[0]
  33.   else
  34.     kveri.ParamByName('osvojeno1').AsString := '/';
  35.  
  36.   if igra = 2 then
  37.   begin
  38.     if memo33.lines[1] = 'da' then
  39.       kveri.ParamByName('osvojeno2').AsString := memo22.lines[1]  
  40.     else
  41.       kveri.ParamByName('osvojeno2').AsString :='/';
  42.   end;
  43.  
  44.   if igra = 3 then
  45.   begin
  46.     if memo33.lines[2] = 'da' then
  47.       kveri.ParamByName('osvojeno3').AsString := memo22.lines[2]
  48.     else
  49.       kveri.ParamByName('osvojeno3').AsString :='/';
  50.   end
  51.   else
  52.     kveri.ParamByName('osvojeno3').AsString :='xxx';
  53.  
  54.   if igra = 4 then
  55.   begin
  56.     if memo33.lines[3] = 'da' then
  57.       kveri.ParamByName('osvojeno4').AsString := memo22.lines[3]
  58.     else
  59.       kveri.ParamByName('osvojeno4').AsString :='/';
  60.   end
  61.   else
  62.     kveri.ParamByName('osvojeno4').AsString :='yyy';
  63.  
  64.   kveri.ParamByName('ukupnoosvojeno').AsString := inttostr(ukupno);
  65.  
  66.   ShowMessage('broj_igraca: ' + kveri.ParamByName('broj_igraca').AsString + LineEnding +
  67.               'imeigraca1:  ' + kveri.ParamByName('imeigraca1').AsString + LineEnding +
  68.               'imeigraca2:  ' + kveri.ParamByName('imeigraca2').AsString + LineEnding +
  69.               'imeigraca3:  ' + kveri.ParamByName('imeigraca3').AsString + LineEnding +
  70.               'imeigraca4:  ' + kveri.ParamByName('imeigraca4').AsString + LineEnding +
  71.               'osvojeno1:   ' + kveri.ParamByName('osvojeno1').AsString + LineEnding +
  72.               'osvojeno2:   ' + kveri.ParamByName('osvojeno2').AsString + LineEnding +
  73.               'osvojeno3:   ' + kveri.ParamByName('osvojeno3').AsString + LineEnding +
  74.               'osvojeno4:   ' + kveri.ParamByName('osvojeno4').AsString + LineEnding +
  75.               'ukupnoosvojeno: ' + kveri.ParamByName('ukupnoosvojeno').AsString);
  76.  
  77.   kveri.ExecSQL;
  78.  
  79.   kon.connected := False;
  80.   kon.databasename := 'myodbc';
  81.   kveri.sql.text := 'select * from pitanja';
  82.   kon.connected := True;
  83.   kveri.active := True;
  84. end;

Mr.Madguy

  • Full Member
  • ***
  • Posts: 203
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #2 on: May 16, 2017, 09:07:25 pm »
Looks like problem isn't with this code - it's with database itself. Can we see database scheme? What type "osvojeno1" parameter is?
Completely overhauling DynamicData 1.0 on it's way to 2.0
Crazy unit testing

nklppc

  • Newbie
  • Posts: 4
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #3 on: May 17, 2017, 07:41:38 am »
Ok ill post it when i get home.

nklppc

  • Newbie
  • Posts: 4
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #4 on: May 17, 2017, 03:03:43 pm »
Here it is in access. http://imgur.com/vEMx4ww

Mr.Madguy

  • Full Member
  • ***
  • Posts: 203
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #5 on: May 17, 2017, 03:50:08 pm »
Yeah. I've found source line, that causes this error: it's line 568 of lazarus\fpc\3.0.2\source\packages\fcl-db\src\sqldb\odbc\odbcconn.pas. And I guess problem is actually with your code. Some parameters are never set and therefore their type is unknown.

You need to change all statements, like this one:
Code: Pascal  [Select]
  1. if igra=2 then if memo33.lines[1]='da' then kveri.Params.ParamByName('osvojeno2').AsString := memo22.lines[1]  else kveri.Params.ParamByName('osvojeno2').AsString :='/';
  2.  
into something like this:
Code: Pascal  [Select]
  1. if (igra=2) and (memo33.lines[1]='da') then kveri.Params.ParamByName('osvojeno2').AsString := memo22.lines[1]  else kveri.Params.ParamByName('osvojeno2').AsString :='/';
  2.  
Completely overhauling DynamicData 1.0 on it's way to 2.0
Crazy unit testing

nklppc

  • Newbie
  • Posts: 4
Re: Parameter 6 is of type unknown, which is not suported yet
« Reply #6 on: May 17, 2017, 04:52:19 pm »
Thanks a lot man those ifs didnt let me create params  :D :D :D :D

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus