467,134 Members | 948 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

SqlDataReader on Sql 2005

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?
Nov 17 '08 #1
  • viewed: 2351
Share:
1 Reply
mastershake (ak*****@gmail.com) writes:
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, es****@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

Nov 18 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ricola ! | last post: by
7 posts views Thread by Franck Diastein | last post: by
3 posts views Thread by Neil Guyette | last post: by
1 post views Thread by Arvind P Rangan | last post: by
3 posts views Thread by rn5a@rediffmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.