Param question

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Param question

Post by ashlar64 » Mon 17 Jul 2006 20:30

Hello!

I create 14 parameters like the 1 line of code below in my form's constructor.

MyQuery_Site_ID->Params->CreateParam(ftInteger, "pram_ut", ptInput);


In another section of code when a user pushes a button I have this code.

Form1->MyQuery_Site_ID->ParamByName("pram_ut")->AsInteger = Form1->MyTable_Version_Utility->RecordCount -2;

After this line of code I generate a very long SQL statement which depends on what the user selects (many checkboxes).

The SQL statement works the first time...but then when I try a second time the SQL statement I generate raises a exception that says:

Project Site_Tracker.exe raised exception class EDatabaseError with message 'Parameter 'pram_ut' not found'. Prcess stopped. Use Step or Run to continue.


Why does this happen?
Does the params property flush out the old params that were created in it when a SQL statement is run in my query?




Also question #2.

When you highlight a TMyQuery object in the design mode...is there any reason why you can't put parameters in the dialog box that pops up? (All the controls on the parameters tab are disabled)


---Dave

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Post by ashlar64 » Mon 17 Jul 2006 20:50

I should also mention that when I create my SQL statement I put it in the SQL property in the TMyQuery object.

Also it does indeed flush out the parameters that it uses.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 18 Jul 2006 09:20

MyQuery parses statement you assign to SQL property and creates parameters automatically. After SQL statement with parameters is set you can access these parameters in both run time (ParamByName) and design time (parameter editor). To prevent automatic parameters recreation you should set ParamCheck option to False.

Guest

Post by Guest » Tue 18 Jul 2006 18:11

When I click the Params in the Object Inspector and click the Parameter tab all the controls in that page are disenabled. Is there a way to enable them?


Thanks for your reply.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 19 Jul 2006 09:34

Please assign SQL statement with parameters to SQL property of the component and go to Parameters tab of the component editor to change properties of parameters used in SQL statement.

Post Reply