Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HOLY CRAP! Is no one using VFP and SQL2008?
Message
De
15/02/2009 18:18:54
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Import/Export
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01381680
Message ID:
01381983
Vues:
45
>>>I've been asking this question for awhile now and have yet to receive any good answers.
>>>
>>>So, now I've finally installed SQL2008 on my machine and I built a table and used the new DATE datatype.
>>>
>>>In VFP I ODBC'd the table down and GUESS WHAT?
>>>
>>>Right! Exactly!
>>>
>>>The DATE datatype gets brought down to VFP as, wait for drum roll... A FREAKING VARCHAR.
>>>
>>>A VARCHAR!
>>>
>>>It's a GD VARCHAR.
>>>
>>>Boyz, we are screwed now. I'm running VFP 9 SP2, so there's nowhere to go to get this one fixed.
>>
>>Jeff,
>>I have missed your question particularly but I have posted various times to various forums that it is the fault of VFP not to interpret return values right. Use SQLNCLI10 and you should be good to go. If you use ODBC driver (SQL Native Client 10.0) then you get the date right but fail on some other new types like xml, varchar(max). Best driver is SQLNCLI10 IMHO. If you use it along with a cursoradapter you wouldn't have problems.
>>Cetin
>
>Cetin,
>
>Can you post the exact connection string that you use? I can't make it work with "SQLNCLI10".

Provider=SQLNCLI10;server=.\sql2008;Trusted_connection=yes;Database=test

Here is data explorer generated code and it works wonderfully well
-Modi comm [enter] (leave the code window open and go to command window)
-At command window type dx[spacebar] and add a connection using the connection string above (editing as needed)
-Expand tables node and drag & drop a table with date on to a code window
* This script handles the ADO Connection and uses a CursorAdapter object
* to retrieve data to a cursor.

PUBLIC oCA as CursorAdapter
LOCAL oConn as ADODB.Connection
LOCAL oRS as ADODB.Recordset
LOCAL oException AS Exception
LOCAL cConnString

* Handle connections - insert connection code
cConnString = [Provider=SQLNCLI10;server=.\sql2008;Trusted_connection=yes;Database=test]

TRY 
    oConn  = createobject('ADODB.Connection')

    * Ensure that you handle userid and password if not 
    * specified in connection string.
    *   ex. oConn.Open(cConnString, userid, password)
    oConn.Open(cConnString)

    oRS = CREATEOBJECT("ADODB.Recordset")
    oRS.DataSource.CursorLocation = 3   &&adUseClient
    oRS.DataSource.LockType = 3   &&adLockOptimistic
    oRS.ActiveConnection = oConn

    oCA=CREATEOBJECT("CursorAdapter")
    oCA.DataSourceType = "ADO"
    oCA.DataSource = oRS
    oCA.MapBinary = .T.
    oCA.MapVarchar = .T.

    oCA.Alias = "test"
    oCA.SelectCmd = "SELECT * FROM test"
    
    IF !oCA.CursorFill()
        * Replace with error code here
        LOCAL laError
        DIMENSION laError[1]
        AERROR(laError)
        MESSAGEBOX(laError[2])
    ELSE
        * Replace with user code here. Code below allows for
        * you to edit and send updates to the backend.
        LOCAL laFlds,lcStr,lnFldCount,i
        DIMENSION laFlds[1]
        lnFldCount=AFIELDS(laFlds)
        lcStr=""
        FOR i = 1 TO lnFldCount
                lcStr = lcStr + laFlds[m.i,1] +  ","
        ENDFOR
        oCA.UpdatableFieldList = lcStr
        BROWSE NORMAL NOWAIT
        LIST STRUCTURE
    ENDIF

CATCH TO oException
    * Replace with exception handling code here
    MESSAGEBOX(oException.Message)

ENDTRY

* Add user code here.
* Note: cursors created by CursorAdapter object are closed when object is released.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform