Connecting Tech Pros Worldwide Help | Site Map

SqlDataReader on Sql 2005

  #1  
Old November 17th, 2008, 10:35 PM
mastershake
Guest
 
Posts: n/a
I'm trying to make some c#. I have a sqldatareader to get the logical
file names from *.BAK files. It works on the default instance but if I
add a named instance it fails. It gives me this:

System.Data.SqlClient.SqlException: A transport-level error has
occurred when sending the request to the server. (provider: TCP
Provider, error: 0 - An existing connection was forcibly closed by the
remote host.)

I don't get this error on the default instance. Any ideas what is
going on?

Here is my sqldatareader code part:

SqlConnection conn = new SqlConnection(getConnStr(instance));
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ln = cmd.ExecuteReader();
string logname = string.Empty;
while (ln.Read())
{
logname += ln[0].ToString() + ",";

}
ln.Close();

Any ideas what is happening?
  #2  
Old November 18th, 2008, 09:25 PM
Erland Sommarskog
Guest
 
Posts: n/a

re: SqlDataReader on Sql 2005


mastershake (akertis@gmail.com) writes:
Quote:
I'm trying to make some c#. I have a sqldatareader to get the logical
file names from *.BAK files. It works on the default instance but if I
add a named instance it fails. It gives me this:
>
System.Data.SqlClient.SqlException: A transport-level error has
occurred when sending the request to the server. (provider: TCP
Provider, error: 0 - An existing connection was forcibly closed by the
remote host.)
>
I don't get this error on the default instance. Any ideas what is
going on?
I'm a little uncertain how to interpret that message. My first reaction
was that it was a result of an internal error in SQL Server or SqlClient,
but maybe it's a network issue.

Could you try with replacing the command with something simple like
"SELECT 12"?
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.NET SQL-powered Sitemap codegecko insights 1 October 27th, 2008 09:19 PM
Connecting to a SQL Server 2005 (Express Edition) database =?Utf-8?B?U2hlcndvb2Q=?= answers 3 June 27th, 2008 08:56 PM
connect vb app to sql 2005 express josh@adnetss.com answers 13 December 18th, 2006 04:05 PM
streaming binary data from sql 2005 answers 6 December 1st, 2005 12:55 PM