Getting parameter not found error at Delphi-SQLite query [Edit]

I am getting error like 'parameter not found' with following SQL query at Delphi

In table emp  
usergroup_id :- integer 
and 
label, description are string data type.

My code is as follows

{code}        
        gid: Integer;
        sdescription,ldescription: String;
        SQLQuery31: TSQLQuery;


        SQLQuery31 := TSQLQuery.Create(nil);
        sdescription := RzEdit1.Text;
        ldescription := RzMemo1.Text;
        gid := Integer(RzComboBox1.Items.Objects[RzComboBox1.Items.IndexOf(gname)]);


        try
            SQLConnection1.Connected := true;
            SQLMonitor1.Active := True;
            SQLQuery31.SQLConnection := SQLConnection1;
            SQLQuery31.SQL.Text := 'INSERT INTO emp(id, usergroup_id, label, description) VALUES (33,":usergroup_id",":label",":description")';
            SQLQuery31.Params.ParseSQL(SQLQuery31.SQL.Text, True);
            SQLQuery31.Params.ParamByName('usergroup_id').Value := gid;
            SQLQuery31.Params.ParamByName('label').Value := sdescription;
            SQLQuery31.Params.ParamByName('description').Value := ldescription;
            SQLQuery31.ExecSQL;
        except
          on E: EDatabaseError do
            ShowMessage('Exception raised with message' + E.Message);
        end;

 {code} 
 
 It is giving me an error as 'Parameter usergroup_id not found' if usergroup_id omitted/ignored then 'Parameter Label not found' etc...
 The fields usergroup_id, label, descreiption etc.. all exists in my SQLite table named 'emp' still why I am getting parameters not found error.
 How to sort out this error ?

Edited by: delphi coder on Oct 7, 2013 7:49 AM
0
delphi
10/7/2013 2:50:07 PM
embarcadero.delphi.ide 3925 articles. 0 followers. Follow

1 Replies
4010 Views

Similar Articles

[PageSpeed] 33

delphi coder wrote:
> I am getting error like 'parameter not found' with following SQL query at Delphi
> 
> In table emp  
> usergroup_id :- integer 
> and 
> label, description are string data type.
> 
> My code is as follows
> 
> {code}        
>         gid: Integer;
>         sdescription,ldescription: String;
>         SQLQuery31: TSQLQuery;
> 
> 
>         SQLQuery31 := TSQLQuery.Create(nil);
>         sdescription := RzEdit1.Text;
>         ldescription := RzMemo1.Text;
>         gid := Integer(RzComboBox1.Items.Objects[RzComboBox1.Items.IndexOf(gname)]);
> 
> 
>         try
>             SQLConnection1.Connected := true;
>             SQLMonitor1.Active := True;
>             SQLQuery31.SQLConnection := SQLConnection1;
>             SQLQuery31.SQL.Text := 'INSERT INTO emp(id, usergroup_id, label, description) VALUES (33,":usergroup_id",":label",":description")';
>             SQLQuery31.Params.ParseSQL(SQLQuery31.SQL.Text, True);
>             SQLQuery31.Params.ParamByName('usergroup_id').Value := gid;
>             SQLQuery31.Params.ParamByName('label').Value := sdescription;
>             SQLQuery31.Params.ParamByName('description').Value := ldescription;
>             SQLQuery31.ExecSQL;
>         except
>           on E: EDatabaseError do
>             ShowMessage('Exception raised with message' + E.Message);
>         end;
> 
>  {code} 
>  
>  It is giving me an error as 'Parameter usergroup_id not found' if usergroup_id omitted/ignored then 'Parameter Label not found' etc...
>  The fields usergroup_id, label, descreiption etc.. all exists in my SQLite table named 'emp' still why I am getting parameters not found error.
>  How to sort out this error ?
> 
> Edited by: delphi coder on Oct 7, 2013 7:49 AM

your SQL is wrong.  Params are prefaced by a :.  Putting the : inside the "" you 
are telling the SQL Parser in Delphi that you are passing a string literal, not 
using a parameter.  Parameters are NOT macro expansions, which is what your SQL 
sort of looks like you are expecting.

  SQLQuery31.SQL.Text := 'INSERT INTO emp(id, usergroup_id, label, description) 
VALUES (33, :usergroup_id, :label, :description)';

You also should not need the "SQLQuery31.Params.ParseSQL(SQLQuery31.SQL.Text, 
True);" line.  I do not think even a prepare is needed with DBX there as first 
use of the params on an unprepared SQL statement will cause a prepare.

-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
10/7/2013 3:40:51 PM
Reply:

Similar Artilces:

Error: "Query: dataset not in Edit mode": in delphi code for Rave Report [Edit]
I am trying to write a Delphi code (Delphi 2010) to print a rave report from the access database; I am using RVSystemprint method; q1 is a query name. I get error message " q1: dataset not in edit or insert mode", at the line: while not q1.Eof. Even though I added q1.Edit or q1.insert, it doesn't work. Database's readonly property is FALSE. What is missing in the code? Thanks. procedure TForm1.rsysPrint(Sender: TObject); begin with Sender as TBaseReport do begin ..... q1.Open; q1.Edit; q1.first; while not q1.Eof do begin ... end; .... ...

Delphi Xe IDE error [Edit]
Hi, Getting the error: "Error in module : Declaration of class T_changeMeBack_s is missing or incorrect" when creating a new project as: New -> Other -> ActiveX Library Then adding New -> Other -> Active Form with the Include about box checked Project is created but the About1.pas file is not visible in the project manager (but a reference to it is found in the uses clause of the created unit and _TLB.pas files Edited by: mark buller on Nov 30, 2012 5:45 PM ...

Delphi 2009 IDE errors
I go to Build or Compile and get an error [DCC Error] E2161 Error: RLINK32: Error opening file "FilenameHere.dfm" It is becuase a file in my USES clause in not open or part of my project. If I open the file first it will compile. (Once it compiles I can close the fileand it still compiles until I exit Delphi 2009) OR If I add the file to my project it will compile. This is a shared unit I do *not* want to include in my project. This worked fine in Delphi 6 and I think in Delphi 2007(although I did not test this exact case to know for sure) The path to the file is in Tools, Op...

SQLite3.dll not found error at Delphi XE3 [Edit]
I have added following controls to the form at Delphi XE3 TSQLConnection, TSQLMonitor, and a TButton. Driver property of the TSQLConnection control to Sqlite. SQLConnection property to SQLConnection1. Caption property of the TButton control to Execute. My code is as follows {code} procedure TForm2.Button1Click(Sender: TObject); var Results: TDataSet; begin SQLConnection1.Params.Add('Database=E:\empn.s3db'); SQLConnection1.LibraryName := 'E:\Delphi-Sample-Project\sqlite3.dll'; //SQLConnection1.Loadlibrary try SQLConnection1....

Delphi XE IDE code parser error ?!? [Edit]
After adding a IdUDPServer to my form and trying to put some code into the OnUDPRead event, I'm not able to add any component to my form at design time, nor can I run the application. here is the error i got: http://i54.tinypic.com/2j5jl0p.jpg i`ve asked about this on StackOverflow and Mike Justin suggested to +remove the +System.+ from +TArray<System.Byte>+ (in the interface and implementation)+, even so then OnUDPRead event doesn`t trigger. To test this i have made a simple app which uses 2 IdUDPServer comps, one to broadcast and one to Listen, works as expected in Delph...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

FireDAC mobile app error as sqlite as delphi XE7 [Edit]
i im trying of connect my app as FireDAC but i have some errors. I follor all steps of Mobile_Tutotils_en_pdf file for delphi XE7. First i add one FireDAConnection compoent, after i in FireDAConnection Edito i set DriverID as Sqlite, in Database parameter i set this existing sqlite database "shoplist.s3db i create this database and table as other tool, and i can to add this to DBExpres in data exploer and i can to use it in one mobile delphi project", and i set lockingmode to normal as this manual tell. After as tell in page 269 of this manual when i click over test button, i ...

Problem with Delphi XE2 using parameters in SQL query [Edit]
Hello, I have problem with using SQL with parameters. This part of code works fine on Delphi 2007, but have Debugger Exception Notification in Delphi XE2 with ADOTmp do *//works fine on Delphi2007 and Delphi XE2, date value is inserted* begin SQL.Clear; *SQL.Add('UPDATE Table SET Date = ''2012-04-03 13:13:13'' ');* ExecSQL; end; with ADOTmp do *//works fine on Delphi2007* begin SQL.Clear; *SQL.Add('UPDATE Table SET Date = :D1 ');* Parameters.ParamByName('D1').DataType := ftDateTime; Parame...

FireDAC mobile app error as sqlite as delphi XE7 [Edit] #2
i im trying of connect my app as FireDAC but i have some errors. I follow all steps of Mobile_Tutotils_en_pdf file for delphi XE7. First i add one FireDAConnection compoent, after i in FireDAConnection Edit i set DriverID as Sqlite, in Database parameter i set this existing sqlite database "shoplist.s3db , and i set lockingmode to normal as this manual tell. I After i follow steps 1,2,3,4 and in the step 5 of the page 265 when i try of to set Connected property to true, i get this error: 1. [FireDac][Comp][Clnt]-340. Driver ID is not defined. Set TFDConnection.DriverName or Add D...

Delphi code thowing errors within IDE (but not in compiled exe) [Edit]
Rad Studio - Delphi 2010 (Windows 7, 64 bit laptop) I started to get some issues with my delphi code not running within my Rad Studio (Delphi) 2010. I have been days trying to figure out why. Working with one installed package after another, trying to decide if it was the culprit or not. After finally uninstalling all packages, and even uninstalling the entire Rad Studio (and re-installing just Rad-Studio), i can't seem to figure what can be causing my Delphi IDE to act as it does. I even cleaned the registry of all things related to my component package a nd Rad Studio (before re-inst...

Delphi 2010 + TIBDatabase + connection error (how to catch error) [Edit]
Hi All Could someone help me in this case: {code} Try DataBase.Connect:=True; Except on >databaseconnectionerror< do ShowMessage('DataBase connection faild); end; {code} I do not know, how to catch (handling) IB errors in my Delphi application. Thank You very much in advance Best Regards Jacek Edited by: Jacek FÄ…gowski on Aug 14, 2012 9:04 AM Jacek FÄ…gowski wrote: > Hi All > > Could someone help me in this case: > {code} > Try > DataBase.Connect:=True; > Except > on >databaseconnectionerror< do > ShowMes...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

New to Delphi
Hi I am new to Delphi & want to know good resources for learning to use it. Is there a list of good Delphi learning resources (books/online tutorials) somewhere? What recommendations can anyone make for someone new to Delphi (& only a hobby programmer at the moment)? A couple of weeks ago I started with DelphiXE4 trial & have Googled for a few Delphi resources but I haven't found anything very good yet for me as a beginner. I'm just struggling along trying to learn as I go! (I'm presently struggling with DragandDrop...see [http://stackoverflow.com/questions/17232...

Error on Delphi 6 but not on Delphi Xe for Ftp
I am Experimenting with get a file from our webside server via Ftp. I have 2 Machines 1 a laptop runing XP Delphi 6 Indy 10.5.8.0 An a machine runing Window 7 Delphi XE2 with Indy 10.5.8.0. I am using the Same Code on Both. procedure TFrmMain.ProcessItemDalySpecial; var PathDest : String; FileName : String; begin with FrmTb2 do begin if ReadIniBoolean(IniCfg,'FTP','UseFtpDaly') then begin Ftp.Host := ReadIniStr(IniCfg,'FTP','HostDaly'); Ftp.Port := ReadIniInt(IniCfg,'FTP'...

Delphi vs Winform
This might be a little techie, but I think most people here are familiar with Delphi to understand the difference between a TWinControl and TGraphicControl. I was trying to create a C# Winform project based on a Delphi prototype and ran into this problem which I posted to some Winform forums ... This led me to an *obvious* deficiency in Winforms programming. I'd like to hear your thoughts. My question to the Winforms forums describing the problem is copied below: <snip> Hi, I mostly do Delphi development but would like to start my next small work project in Visual S...

Update Delphi 2005 to Delphi 2010, which do i need? [Edit]
Hello, we have one Delphi 2005 Professional here and want to upgrade to Delphi 2010, but we are a bit confused. Our distributor in Germany, ingram-micro offers several upgrade products: UPG DELPHI 2010 PRO - NAMED USER UPG DELPHI 2010 PRO - NAMED USER ELS UPG DELPHI 2010 PRO - NAMED USER FLEX RAD STUDIO 2010 PRO - UPG UPG RAD STUDIO 2010 PRO - NAMED ELC UPG RAD STUDIO 2010 PRO - NAMED FLEX UPG DELPHI 2010 PRO - CONCURRENT ELS UPG DELPHI 2010 PRO - CONCURRENT FLEX What do they mean exactly and which one do i need? At the moment delphi is installed on two PCs and we want to use ...

Delphi 2006 vs Delphi 2009 IDE stability
Hello, all. I have medium sized project which includes about 20Mb of source code (just size of *.pas files). I use Delphi 2006. There are third party component suites JVCL, DevExpress Bars, Pegasus Imaging. All updates applied. The main problem is IDE stability. About four..five times a day IDE become unstable after intensive usage of code insight functions (most often I press Ctrl+Space key). The best outcome is that I have to save everything and restart the IDE. The worst outcome is when IDE stalls or falls into endless loop of error messages and any unsaved work is lost. OS...

Delphi 7 to Delphi XE: TBlobField to XML [Edit]
Hi, I'm migrating a Delphi7 application to Delphi XE. I'm using a TClientDataSet to communicate, by using a XML frame, with my server. In this TClientDataSet I'm using a TBlobField which is an array of 384 byte. The blobField is allocate by a code like this : {code} myStream : TStream; myStream := aClientDataSet.CreateBlobStream(myBlobField, bmwrite); vResult := myStream.Write(ArrayOf384Byte[0], length(ArrayOf384Byte)); //vResult = 384 => GooD ! (...) {code} For communicate with the server, we have to decode the Blobfield in XML before to sending it. We have override the ApplyUpdate. In the new applyupdate, we are converting NewValue in base64 by a code like this : {code} aXmlString := StringToBase64(myBlobField.NewValue) {code} The problem is than in Delphi 7 the length of NewValue was correct (384), but in DXE this length is random (between 50 and 250 ??) (it's as if a character was an end of string) => There is data loss, so the XML string is bad and my server is crashing. I don't understand what happened between writing in the BlobField and reading the BlobField's property "newValue"??? Why the value was correct in Delphi 7 and bad in XE? What was changed in the ClientDataSet mechanism? Is it a problem of unicode migration? Any help will be appreciated. Thanks, Gwen Edited by: Gwénaël Manceau on Oct 20, 2011 9:46 AM I solved my problem by using {code} aXmlString := Stri...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

Code works in Delphi 7 but not in Delphi 2010 [Edit]
hello, i have a procedure that open's a file by passing the file name as the parameter to the executable. something like this {code} C : \ P r o g r a m F i l e s \ Da c k e r \ D r a c k e r . e x e " G : \ D E l p h i 7 \ D e l p h i 7 A p p _ l o g . t " {code} The source code is {code} procedure OpenFileWithExe var hReg: HKEY; Ret: Longint; RegDataType, RegDataSize: DWORD; CmdLine: array [0..560] of Char; Len: Integer; SInfo: TStartupInfo; PInfo: TProcessInformation; begin Ret := windows.RegOpenKeyEx(HKEY_CURRENT_USER, ...

Migrating from Delphi 6 to Delphi XE 3! [Edit]
All, I am a Delphi developer working in an windows form application developed using Delphi 6. Now, we are planning to upgrade the development tool. Can anyone provide me information related to major roadblocks that we can face while migrating from Delphi 6 to Delphi XE 3? Should we migrate to Delphi XE 3 or any other preferred version of Delphi based on the fact that our target users will be using Windows 7 or Windows 8? Do we have any tools or utilities to migrate the source code from Delphi 6 to higher version of Delphi? Also, any suggestions related to best practices are welcome....

Delphi 2006 Error [Edit]
Here is a problem I am having with Delphi 2006: There is an application that was written on Delphi 5. It was working without any problems - the source code would compile flawlessly. I need to make this code work in Delphi 2006. Everything works fine, the source code would compile without any problem, and the application itself runs fine. However, whenever I _close_ the application, I get the following errors: "Access violation at address 00474F39 in module 'wts.exe'. Read of address 0000001C" Picture: http://i47.tinypic.com/149tjs1.jpg Once I click on "OK...

Delphi XE HTTP: error "Socket Error #10054 Connection reset by peer" [Edit]
Communication type is set to HTTP, LifeCycle is set to Invocation. Invocation represents a stateless connection, but when the network connection drops, the client throws the error "Socket Error #10054 Connection reset by peer". Are there any other properties to set up apart from LifeCycle? Hi Irina, > Communication type is set to HTTP, LifeCycle is set to Invocation. > > Invocation represents a stateless connection, but when the network connection drops, the client throws the error "Socket Error #10054 Connection reset by peer". Are there any other proper...

ArcGIS runtime errors after upgrading from Delphi 2007 to Delphi XE3
We have an application written in Delphi Pascal that accesses the ArcGIS 9.3 API through the COM interface. We recently upgraded from Delphi 2007 to Delphi XE3 and ever since we upgraded we have been getting runtime errors in the ArcGIS libraries that we were not getting before. Specifically the error is always "invalid floating point operation". The first one that was occurring was happening in the method "sg.SgCoordRefSetZ". I was able to eliminate this error by adding a call to FGeoSpatialReference.SetZDomain(-10000, 100000.0) even though there is nowhere that we&#...

Web resources about - Getting parameter not found error at Delphi-SQLite query [Edit] - embarcadero.delphi.ide

Resources last updated: 3/7/2016 11:59:14 AM