Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Empty Date from SQL Server via ODBC/CursorAdapter
Message
De
08/09/2005 16:02:26
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Empty Date from SQL Server via ODBC/CursorAdapter
Versions des environnements
Visual FoxPro:
VFP 9
Database:
MS SQL Server
Divers
Thread ID:
01047852
Message ID:
01047852
Vues:
74
Hey all,

I'm working on a project that uses CursorAdapter to translate data between SQL Server and VFP cursors. We are using lots of existing code that should be changed as little as possible. All is going well, except for a sticky problem I'm working on right now.

Our datetimes in SQL Server will be NULL if there is no valid value in them (we are NOT using 01-01-1900). We want the datetime values in the VFP cursor, however, to be empty instead of NULL.

I'm using the outgoing ConversionFunc property of CursorAdapter to convert empty dates to NULL when updating or inserting, but I'm looking for a way to do the converse when querying up existing records from SQL Server. So, I created a new .cIncomingConversionFunc property and a corresponding .DoConversions method that is called in the AfterCursorFill method to post-process the cursor.

This works just fine, except that it dirties the buffer. I can, of course, add more code to use SETFLDSTATE on each affected field in each affected record, but I thought it best to first ask here if I'm missing anything on the SQL Server side that would make this post-processing unnecessary.

Specifically, is there anything you can do in the SELECT statement in SQL Server to return an empty date if null? (I don't think so, since ALL dates in SQL Server either have a value or a null). So, I don't think ISNULL will do me any good. Also, VFP won't accept a character field in the Select statement and auto-convert it to the Date-type field I have defined in CursorSchema, so sending a string back from SQL Server does not seem to be an option.

Is there anything else I'm missing -- perhaps an ODBC setting of some kind -- that can help with this? Otherwise, I'll just add more code to the post-processing to reset the field state.

Also, is there any shortcut to use SETFLDSTATE to set ALL fields back to status 1 with 1 command?
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform