I know. I should not use System.Data.SqlClient, but I have no alternatives, so, can you help me?
I have installed using NuGet the System.Data.SqlClient and write some code to connect to a SQLSERVER 2000 DB.
My code works fine on a WinForms app.
Then I try to use it in a XF app. It seems to work but I have an exception when I try to open the connection:
"The SQL Server instance returned an invalid or unsupported protocol version"
It seems that I can't connect to a SQLSERVER 2000 DB because it is not supported..
Is this correct?
I have tried also the new Microsoft.Data.SqlClient, but it does not work at all (a nullreferenceexception is thrown).
Thanks for your help
internal void Test()
{
//openConnection();
string command = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
try
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString()))
{
SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);
sqlConnection.Open();
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
while (sqlDataReader.Read())
{
System.Diagnostics.Debug.WriteLine("Tablename = " + sqlDataReader[0].ToString());
}
sqlConnection.Close();
sqlConnection.Dispose();
}
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
string connectionString()
{
string connectionString = "Server=tcp:" + _ipServer + ";" +
"Initial Catalog=MYDB;" +
"User Id=sa;" +
"Password=;";
return connectionString;
}