-
1
- #1
One of my client's applications supports three different database servers, so it is important to create SQL commands that function identically in all of them.
One of my techniques is to use the ODBC scalar function Convert, which can convert (among other things) a character string to a date. I use this when building WHERE clauses for my SQL statements.
For example, say I have a control on a form where a user types in or selects a date, and this control uses a character-type value. When building my SQL statement, I can ensure this value is properly handled as a date on the server by using the ODBC Convert function thusly:
[tt]"post_dt={fn CONVERT('" + MyControl.Value + "', SQL_DATE)} "[/tt]
When the statement is eventually sent to the database via the ODBC driver, the driver sees the pair of curly braces {} and knows it needs to apply some processing. It then converts MyControl.Value to a date type appropriate to the currently-connected database. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
One of my techniques is to use the ODBC scalar function Convert, which can convert (among other things) a character string to a date. I use this when building WHERE clauses for my SQL statements.
For example, say I have a control on a form where a user types in or selects a date, and this control uses a character-type value. When building my SQL statement, I can ensure this value is properly handled as a date on the server by using the ODBC Convert function thusly:
[tt]"post_dt={fn CONVERT('" + MyControl.Value + "', SQL_DATE)} "[/tt]
When the statement is eventually sent to the database via the ODBC driver, the driver sees the pair of curly braces {} and knows it needs to apply some processing. It then converts MyControl.Value to a date type appropriate to the currently-connected database. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]