I have an application written in Delphi 5 that uses query components working against a SQL server 7.0 database. If I have queries with hard-coded SQL syntax (i.e. 'SELECT [FirstName], [Surname] FROM [Users] WHERE [UserID] =UserID) then I can set the parameter types (in this case the parameter 'pUserID' can have 'Integer' set as the parameter type). If I am dynamically setting the SQL syntax for the query components at run-time (according to the tables I want to retrieve data from) how do I set the data-types for the parameters. If I do not set the parameter types and try to activate one of these queries and attempt to clear one of the parameters (using 'Query1.Params[1].Clear') I get an error message indicating that the parameter type is not known and the application halts.
The only way round this (found through much trial and error) was to have a line of code 'Query1.Params[1].AsInteger := 0' before the clearing of parameter. This then tells the program that the parameter is of type 'Integer' and then allows us to clear the parameter type.
Is this the best way to handle this issue - or is there a better method ?
Thanks in advance.
Steve
The only way round this (found through much trial and error) was to have a line of code 'Query1.Params[1].AsInteger := 0' before the clearing of parameter. This then tells the program that the parameter is of type 'Integer' and then allows us to clear the parameter type.
Is this the best way to handle this issue - or is there a better method ?
Thanks in advance.
Steve