Hi all,
i wasn't sure what forum to post this in, so i'll try here, altho it might be more appropriate for a SQL forum.
I have a C# Service which uses a SQLCommand object to insert a record into a table. This code has been running fine, except last night I was running a query on the table pickuplog, just some counts which all worked fine. But at the same time, my service caused an error. Is it not possible for an insert command from a service to run while a user is running a select statement through Enterprise Manager? Error text and code to follow:
Message: General network error. Check your network documentation.
Trace: at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Namespace.class.DBF2XML() in c:\folder\XML Generation\folder\program.cs:line 474
Code:
command.CommandText = "insert into pickuplog (
field1, field2, field3, field4, field5, field6, field7)";
command.CommandText+= " values (@field1, @field2, @field3, @field4, @field5, @field6, @field7)";
if (command.Parameters.Contains("@field1") == false)
{
command.Parameters.Add("@field1",SqlDbType.NVarChar);
command.Parameters.Add("@field2",SqlDbType.NVarChar);
command.Parameters.Add("@field3",SqlDbType.NVarChar);
command.Parameters.Add("@field4",SqlDbType.DateTime);
command.Parameters.Add("@field5",SqlDbType.Char);
command.Parameters.Add("@field6",SqlDbType.VarChar);
command.Parameters.Add("@field7",SqlDbType.NVarChar);
}
command.Parameters["@field1"].Value = strValue;
command.Parameters["@field2"].Value = strValue;
command.Parameters["@field3"].Value = strValue;
command.Parameters["@field4"].Value = strValue;
command.Parameters["@field5"].Value = strValue;
command.Parameters["@field6"].Value = strValue;
command.Parameters["@field6"].Value = strValue;
command.ExecuteNonQuery(); // This is where the error was logged