Database.ExecuteNonQuery does not return

Posted by dan-waterbly on Stack Overflow See other posts from Stack Overflow or by dan-waterbly
Published on 2010-04-15T17:07:44Z Indexed on 2010/04/16 18:53 UTC
Read the original article Hit count: 248

Filed under:
|
|
|
|

I have a very odd issue. When I execute a specific database stored procedure from C# using SqlCommand.ExecuteNonQuery, my stored procedure is never executed.

Furthermore, SQL Profiler does not register the command at all. I do not receive a command timeout, and no exeception is thrown.

The weirdest thing is that this code has worked fine over 1,200,000 times, but for this one particular file I am inserting into the database, it just hangs forever.

When I kill the application, I receive this error in the event log of the database server: "A fatal error occurued while reading the input stream from the network. The session will be terminated (input error: 64, output error: 0). Which makes me think that the database server is receiving the command, though SQL Profiler says otherwise.

I know that the appropiate permissions are set, and that the connection string is right as this piece of code and stored procedure works fine with other files.

Below is the code that calls the stored procedure, it may be important to note that the file I am trying to insert is 33.5MB, but I have added more than 10,000 files larger than 500MB, so I do not think the size is the issue:

using (SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["TheDatabase"].ConnectionString))
using (SqlCommand command = sqlconn.CreateCommand())
{
    command.CommandText = "Add_File";
    command.CommandType = CommandType.StoredProcedure;
    command.CommandTimeout = 30 //should timeout in 30 seconds, but doesn't...
    command.Parameters.AddWithValue("@ID", ID).SqlDbType = SqlDbType.BigInt;
    command.Parameters.AddWithValue("@BinaryData", byteArr).SqlDbType = SqlDbType.VarBinary;
    command.Parameters.AddWithValue("@FileName", fileName).SqlDbType = SqlDbType.VarChar;
    sqlconn.Open();
    command.ExecuteNonQuery();
}

There is no firewall between the server making the call and the database server, and the windows firewalls have been disabled to troubleshoot this issue.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server