Page 1 of 1

Param question

Posted: Mon 17 Jul 2006 20:30
by ashlar64
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

Posted: Mon 17 Jul 2006 20:50
by ashlar64
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.

Posted: Tue 18 Jul 2006 09:20
by Antaeus
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.

Posted: Tue 18 Jul 2006 18:11
by Guest
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.

Posted: Wed 19 Jul 2006 09:34
by Antaeus
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.