Check the type of a field in a query
Posted on 2006-07-05
I have several questions...
I'm trying to use a variable in a query similar to the following
Query1.SQL.Text := 'SELECT name FROM Table WHERE Value = :MyVal';
Query1.ParamByName('MyVal').Value := EditBox.Text;
My problem is that if Value is an integer then my Query won't accept the value and will give me an error. I'm not sure of the best solution to this I think I need to check the type of 'Value' and assign the variable MyVal a value based on the type. Is there a way I can check the type of a particular field in a db?
I'm getting input from EditBoxes and using it similar to above for things that should be integers I only want to have users able to enter numeric data into the field or check whether what they entered is a number before I assign the value to my query is there a function that does this?
3) if Value above in part 1 is a string and the text in my EditBox contains apostrophes do I need to edit the field at all so that the Query doesn't directly interpret the apostrophes.