Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2008, 09:44 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# Service Sql Table network error

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


 
Old June 27th, 2008, 08:18 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Update: I was able to reproduce problem. I opened a table in Enterprise Manager, put the cursor in a cell (i wanted to copy and paste the value for an email). At the same time an ExecuteNonQuery was running from my service on the table, and it bombed. So I guess no more enterprise manager, heh.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to give network service previlages using nant kalpana2009 NAnt 1 October 22nd, 2007 09:16 AM
failed for user 'NT AUTHORITY\NETWORK SERVICE' GS ASP.NET 2.0 Professional 5 March 26th, 2007 05:16 AM
user 'NT AUTHORITY\NETWORK SERVICE' GS ASP.NET 2.0 Basics 0 March 25th, 2007 10:58 AM
Enabling write permissions for NETWORK SERVICE and amatytfc ASP.NET 2.0 Basics 3 January 17th, 2007 12:58 PM
The current identity (NT AUTHORITY\NETWORK SERVICE babakwx ASP.NET 2.0 Professional 1 May 20th, 2006 10:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.