Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Driver vs more recent ODBC driver
Message
 
 
À
21/11/2018 01:01:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01663573
Message ID:
01663638
Vues:
56
>Naomi,
>
>You can use this tester to see the effect of different drivers while fetching SQL Server data. It's a revised version of another one that I already posted here.
>
>As far as I can tell, and so far, the most comprehensive driver seems to be the Devart one. Although the "original" SQL Server driver fails to correctly map some types, at least it can fetch the data - whatever type they may have - as character.
>
>
>LOCAL MSSQLStmt AS String
>CLEAR
>
>CURSORSETPROP("MapBinary",.T.,0)
>CURSORSETPROP("MapVarchar",.T.,0)
>
>* set your server and credentials
>#DEFINE SERVER_NAME	""
>#DEFINE USER_LOGIN	""
>#DEFINE USER_PWD		""
>
>TEXT TO m.MSSQLStmt NOSHOW
>SELECT CAST(GETDATE() AS date) as t_date, 
>	CAST(GETDATE() AS datetime) as t_datetime,
>	CAST(GETDATE() AS datetime2) as t_datetime2,
>	CAST(GETDATE() AS smalldatetime) AS t_smalldatetime,
>	CAST(GETDATE() AS time) AS t_time,
>	CAST(GETDATE() AS datetimeoffset) AS t_datetimeoffset,
>	CAST(1 AS bigint) AS t_bigint,
>	CAST(1.1 AS float) AS t_float, 
>	CAST(1.1 AS real) AS t_real,
>	CAST(1.1 AS numeric(10,2)) AS t_numeric10_2,
>	CAST(1 AS bit) AS t_bit,
>	CAST('Žižek' AS char(10)) AS t_char10,
>	CAST('Žižek' AS varchar(10)) AS t_varchar10,
>	CAST('Žižek' AS text) AS t_text,
>	CAST('Žižek' AS char(256)) AS t_char256,
>	CAST('Žižek' AS varchar(256)) AS t_varchar256,
>	CAST('Žižek' AS nchar(10)) AS t_nchar10,
>	CAST('Žižek' AS nvarchar(10)) AS t_nvarchar10,
>	CAST('Žižek' AS ntext) AS t_ntext,
>	CAST('Žižek' AS nchar(256)) AS t_nchar256,
>	CAST('Žižek' AS nvarchar(256)) AS t_nvarchar256,
>	CAST('Žižek' AS varchar(max)) AS t_varcharmax,
>	CAST('Žižek' AS nvarchar(max)) AS t_nvarcharmax,
>	CAST('Žižek' AS varbinary(max)) AS t_varbinary,
>	NEWID() AS t_uniqueidentifier
>ENDTEXT
>
>* uncomment where needed, add new drivers if installed
>MSSQL2VFP_Types("SQL Server", m.MSSQLStmt)
>MSSQL2VFP_Types("SQL Server Native Client 10.0", m.MSSQLStmt)
>MSSQL2VFP_Types("SQL Server Native Client 11.0", m.MSSQLStmt)
>MSSQL2VFP_Types("ODBC Driver 13 for SQL Server", m.MSSQLStmt)
>MSSQL2VFP_Types("ODBC Driver 17 for SQL Server", m.MSSQLStmt)
>MSSQL2VFP_Types("Devart ODBC Driver for SQL Server", m.MSSQLStmt)
>
>PROCEDURE MSSQL2VFP_Types (Driver AS String, SQLStmt AS String)
>LOCAL ODBC AS Integer
>LOCAL Cols AS Integer
>
>m.ODBC = SQLSTRINGCONNECT("Driver={" + m.Driver + "};Server=" + SERVER_NAME + ";" + ;
>									"Uid=" + USER_LOGIN + ";Pwd=" + USER_PWD)
>
>?
>? m.Driver FONT "Arial",14 STYLE "B"
>
>IF m.ODBC != -1
>	SQLEXEC(m.ODBC, m.SQLStmt, "curCols")
>	FOR m.Cols = 1 TO FCOUNT("curCols")
>		? PADR(SUBSTR(FIELD(m.Cols, "curCols", 0), 3), 20, ".")
>		?? TYPE(FIELD(m.Cols, "curCols"))
>		?? " = [" + IIF(TYPE(FIELD(m.Cols, "curCols"))=="G","general",TRANSFORM(EVALUATE(FIELD(m.Cols, "curCols")))) + "] / " + ;
>			TRANSFORM(FSIZE(FIELD(m.Cols, "curCols"), "curCols"))
>	ENDFOR
>	SQLDISCONNECT(m.ODBC)
>	
>	WAIT WINDOW "Click to continue..."
>ELSE
>	? "Not available..."
>	?
>ENDIF
>
>ENDPROC
>
Thanks, Antonio. I didn't have a few drivers and I see that both native and ODBC 13 have problem with varchar(max).
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform