Internal Connection fatal error while reading from a sqldatareader RRS feed

  • Question

  • Hi ,

    I have an application(VS 2012) written in C# and using Sql 2012 as backend.

    I am getting aInternal Connection fatal error while reading from the sqldatareader.

    this is my code where  i am getting error.

    using (SqlDataReader documents = databaseConnector.Execute("sp_SELECT_G", databaseParameters)) 

    while (documents.Read())

    {    //CODE                     } 


    the full stack of error is as below.

    Internal connection fatal error

    at System.Data.SqlClient.TdsParserStateObject.TryProcessHeader()

    at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer() 

    at System.Data.SqlClient.TdsParserStateObject.TryReadByteArray(Byte[] buff, Int32 offset, Int32 len, Int32& totalRead) 

    at System.Data.SqlClient.TdsParser.TrySkipPlpValue(UInt64 cb, TdsParserStateObject stateObj, UInt64& totalBytesSkipped) 

    at System.Data.SqlClient.TdsParser.TrySkipValue(SqlMetaDataPriv md, Int32 columnOrdinal, TdsParserStateObject stateObj) 

    at System.Data.SqlClient.TdsParser.TrySkipRow(_SqlMetaDataSet columns, Int32 startCol, TdsParserStateObject stateObj) 

    at System.Data.SqlClient.SqlDataReader.TryCleanPartialRead()   at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more) 

    at System.Data.SqlClient.SqlDataReader.Read()


    Could any one please help me regarding this..

    Thanks in advance


    • Edited by Sampru Thursday, February 27, 2014 8:07 PM
    Thursday, February 27, 2014 6:00 PM

All replies

  • Hello,

    Does it has error message? How do you write the store procedure “sp_SELECT_G “?

    What is the databaseConnector object? As far as I know, the SqlDataReader object should be returned by:

               SqlDataReader reader = cmd.ExecuteReader();
    Could please provide more information? With ambiguous information, we can do nothing for you.

    Friday, February 28, 2014 2:24 AM
  • Hello Samproe,

    As what StartTodayNeverTomorrow has said, if you can provide more detail information, we will help you better.

    And from your code, if I understand correctly, you want to use the SqlDataReader to read data from a store procedure, here I make an example:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    namespace P201401
        class TestForReaderWithSP
            internal void Execute()
                string connectionString = @"Data Source=(localdb)\v11.0;Initial Catalog=DataBaseFirstDB;Integrated Security=True";
                SqlConnection connection = new SqlConnection(connectionString);
                    SqlParameter parameter = new SqlParameter("@param1", 1);
                    SqlCommand cmd = new SqlCommand("ProQueryOrder @param1", connection);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.HasRows && reader.Read())
                        Console.WriteLine(reader.GetInt32(0) + "," + reader.GetString(1) + "," + reader.GetString(2));
                    Console.WriteLine("Connect Success!");
                catch (Exception ex)

    My store procedure:

    CREATE PROCEDURE [dbo].[ProQueryOrder]
           @param1 int
           select * from [Order] where [Order].OrderID = @param1 
    return 0

    You can have a try.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 28, 2014 6:38 AM