G
Guest
Hi
I have been using the SqlConnection class in version 1.1 for a while with no
problems. I have now converted my code across to version 2.0 and the open is
now incredibly slow. The exact same code takes 20 seconds to open the
connection when compiled using 2.0 and opens almost instantly when compiled
using 1.1. I have also tried using OleDb instead of SqlClient and this works
fine in 2.0 opening the connection almost immediately.
DateTime startTime = DateTime.Now;
System.Data.SqlClient.SqlConnection connection = new
System.Data.SqlClient.SqlConnection();
connection.ConnectionString = "Data Source=Server1; Initial Catalog=Master;
Integrated Security=SSPI; Connect Timeout=100;";
connection.Open();
System.Data.SqlClient.SqlCommand command = new
System.Data.SqlClient.SqlCommand();
command.Connection = connection;
command.CommandText = "sp_who";
command.CommandType = CommandType.StoredProcedure;
System.Data.SqlClient.SqlDataReader dataReader = command.ExecuteReader();
dataReader.Close();
connection.Close();
MessageBox.Show("Time = " + (DateTime.Now - startTime).ToString());
Thanks in advance
Peter
I have been using the SqlConnection class in version 1.1 for a while with no
problems. I have now converted my code across to version 2.0 and the open is
now incredibly slow. The exact same code takes 20 seconds to open the
connection when compiled using 2.0 and opens almost instantly when compiled
using 1.1. I have also tried using OleDb instead of SqlClient and this works
fine in 2.0 opening the connection almost immediately.
DateTime startTime = DateTime.Now;
System.Data.SqlClient.SqlConnection connection = new
System.Data.SqlClient.SqlConnection();
connection.ConnectionString = "Data Source=Server1; Initial Catalog=Master;
Integrated Security=SSPI; Connect Timeout=100;";
connection.Open();
System.Data.SqlClient.SqlCommand command = new
System.Data.SqlClient.SqlCommand();
command.Connection = connection;
command.CommandText = "sp_who";
command.CommandType = CommandType.StoredProcedure;
System.Data.SqlClient.SqlDataReader dataReader = command.ExecuteReader();
dataReader.Close();
connection.Close();
MessageBox.Show("Time = " + (DateTime.Now - startTime).ToString());
Thanks in advance
Peter