0

I'm currently using an OLEDB connection to connect to SQL Server 2016 for all my submodules which utilize a connection string containing a special keyword: DataTypeCompatibility.

Ex:

Provider=SQLNCLI11;Server=servername;Database=myDatabaseName;Persist Security Info=False;DataTypeCompatibility=80;User ID=foo;

Is there a way to modify a SqlParameter connection string to use a DataTypeCompatibility keyword within my legacy code?

mySQLConn = New SqlConnection()
mySQLConn.ConnectionString = strConn
mySQLConn.Open()

SQLcommand= New SqlCommand("stored_procedure", mySQLConn)
SQLcommand.CommandType = CommandType.StoredProcedure
SQLcommand.CommandTimeout = 0
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    I am not following your question. `DataTypeCompatibility` is specific to OLEDB for type mapping when using sql server 2005 (not sure about versions beyond that). If you write code using System.Data.SqlClient types this is no longer needed as type mapping is handled automatically. Also you cant mix and match between ADO provider types, meaning you could not use a SqlParameter in an OleDbCommand (for example). – Igor Jan 11 '22 at 20:56
  • 1
    As for a recommendation I would write any new code using System.Data.SqlClient types when having to write ado.net code. This will give you better flexibility and performance when connecting to a sql server database. – Igor Jan 11 '22 at 20:57
  • This is a follow-up to https://stackoverflow.com/q/70671913/11683. – GSerg Jan 11 '22 at 21:25

0 Answers0