开发者

Database.ExecuteNonQuery does not return

开发者 https://www.devze.com 2022-12-27 05:20 出处:网络
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.

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();
}

开发者_如何学GoThere is no firewall between the server making the call and the database server, and the windows firewalls have been disabled to troubleshoot this issue.


I've seen this once before when uploading XML via a stored proc from one workstation only

We changed the network cable (which routed differently in our big building) and it worked.

Bizarre as this sounds, can you somehow re-mount the server or change cables or bypass a switch etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消