473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

SqlException

System.Data.SqlClient.SqlException: General network error.
Check your network documentation. I know that this is not
much to go on. But I don't know where to start. the
program updates 186 records and on the 187 record I get
this error. I know this don't make any sense but the code
field has sa in it?

When it bombs I have this in the fields.
ProdIDkey = 488
Name = 10ct diamond & 1.25 Sapphire ring
Code = r1364sa
Caption = 10ct diamond & 1.25 Sapphire ring
Price = 597
SalePrice = 327
CategoryKey = 68
path = Rings:Diamond:Gold:14 Kt:White:

CREATE PROCEDURE Update_CSV
@ProdIDkey int,
@Name nvarchar(255),
@code nvarchar(255),
@Caption nvarchar(4000),
@Price int,
@SalePrice int,
@CategoryKey int,
@path nvarchar(255)

as
DECLARE @CountItems int

SELECT
@CountItems = Count(*)
FROM CSV

WHERE ProdIDkey = @ProdIDkey
IF @CountItems > 0 /* There are items - update the
current quantity */

UPDATE CSV
SET Name = @Name, code = @code, Caption =
@Caption, Price = @Price, [Sale-Price] = @SalePrice,
CategoryKey = @CategoryKey, path = @path
WHERE ProdIDkey = @ProdIDkey

ELSE /* New entry for this Cart. Add a new record */

INSERT INTO CSV
(Name, code, Caption, Price, [Sale-
Price], CategoryKey, path,ProdIDkey)
VALUES (@Name, @code, @Caption, @Price, @SalePrice,
@CategoryKey, @path,@ProdIDkey)
GO

Jul 19 '05 #1
2 3073
First of all, every stored procedure should have SET NOCOUNT ON as
the first statement. Second, you need to implement error handling in
the stored procedure, not rely on the client (SqlException). Here are
two free papers contributed by SQL Server MVP Erland Sommarskog, which
have excellent coverage of the topic:

"Error Handling in SQL Server - a Background",
http://www.algonet.se/~sommar/error-handling-I.html and
"Implementing Error Handling with Stored Procedures",
http://www.algonet.se/~sommar/error-handling-II.html

-- Mary
MCW Technologies
http://www.mcwtech.com

On Wed, 16 Jul 2003 15:47:13 -0700, "stanley J mroczek"
<sm******@si.rr.com> wrote:
System.Data.SqlClient.SqlException: General network error.
Check your network documentation. I know that this is not
much to go on. But I don't know where to start. the
program updates 186 records and on the 187 record I get
this error. I know this don't make any sense but the code
field has sa in it?

When it bombs I have this in the fields.
ProdIDkey = 488
Name = 10ct diamond & 1.25 Sapphire ring
Code = r1364sa
Caption = 10ct diamond & 1.25 Sapphire ring
Price = 597
SalePrice = 327
CategoryKey = 68
path = Rings:Diamond:Gold:14 Kt:White:

CREATE PROCEDURE Update_CSV
@ProdIDkey int,
@Name nvarchar(255),
@code nvarchar(255),
@Caption nvarchar(4000),
@Price int,
@SalePrice int,
@CategoryKey int,
@path nvarchar(255)

as
DECLARE @CountItems int

SELECT
@CountItems = Count(*)
FROM CSV

WHERE ProdIDkey = @ProdIDkey
IF @CountItems > 0 /* There are items - update the
current quantity */

UPDATE CSV
SET Name = @Name, code = @code, Caption =
@Caption, Price = @Price, [Sale-Price] = @SalePrice,
CategoryKey = @CategoryKey, path = @path
WHERE ProdIDkey = @ProdIDkey

ELSE /* New entry for this Cart. Add a new record */

INSERT INTO CSV
(Name, code, Caption, Price, [Sale-
Price], CategoryKey, path,ProdIDkey)
VALUES (@Name, @code, @Caption, @Price, @SalePrice,
@CategoryKey, @path,@ProdIDkey)
GO


Jul 19 '05 #2
I read
"Error Handling in SQL Server - a Background",
http://www.algonet.se/~sommar/error-handling-I.html and
"Implementing Error Handling with Stored Procedures",
http://www.algonet.se/~sommar/error-handling-II.html

and made the following changes:

if I take out the try I still get the error and I know how to find
whats wrong.

Please hekp??
Stan
-----------------------------------------------------------
Public Function CSVUpdate(ByVal Name As String, _
ByVal code As String, _
ByVal Caption As String, _
ByVal Price As Integer, _
ByVal SalePrice As Integer, _
ByVal id As String, _
ByVal path As String)

' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("Update_CSV",
myConnection)

' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim parameterName As SqlParameter = New
SqlParameter("@Name", SqlDbType.NVarChar, 255)
parameterName.Value = Name
myCommand.Parameters.Add(parameterName)

Dim parametercode As SqlParameter = New
SqlParameter("@code", SqlDbType.NVarChar, 255)
parametercode.Value = code
myCommand.Parameters.Add(parametercode)

Dim parameterCaption As SqlParameter = New
SqlParameter("@Caption", SqlDbType.NVarChar, 4000)
parameterCaption.Value = Caption
myCommand.Parameters.Add(parameterCaption)
Dim parameterPrice As SqlParameter = New
SqlParameter("@Price", SqlDbType.Int, 4)
parameterPrice.Value = Price
myCommand.Parameters.Add(parameterPrice)

Dim parameterSalePrice As SqlParameter = New
SqlParameter("@SalePrice", SqlDbType.Int, 4)
parameterSalePrice.Value = SalePrice
myCommand.Parameters.Add(parameterSalePrice)

Dim parameterid As SqlParameter = New SqlParameter("@Id",
SqlDbType.NVarChar, 255)
parameterid.Value = id
myCommand.Parameters.Add(parameterid)

Dim parameterpath As SqlParameter = New
SqlParameter("@path", SqlDbType.NVarChar, 255)
parameterpath.Value = path
myCommand.Parameters.Add(parameterpath)

Dim parametererr As SqlParameter = New SqlParameter("@err",
SqlDbType.Int, 4)
parametererr.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parametererr)

Try
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
Catch myException As SqlException
Dim errornumber As Integer = CInt(parametererr.Value)
End Try
myConnection.Close()

------------------------------------------------------------------------
----
CREATE PROCEDURE Update_CSV

@Name nvarchar(255),
@code nvarchar(255),
@Caption nvarchar(4000),
@Price int,
@SalePrice int,
@id nvarchar(255),
@path nvarchar(255),
@err int output
as
SET NOCOUNT ON

DECLARE @CountItems int

SELECT
@CountItems = Count(*)
FROM CSV

WHERE code = @code
IF @CountItems > 0 /* There are items - update the current quantity */

UPDATE CSV
SET Name = @Name, code = @code,Id = @id, Caption =
@Caption, Price = @Price, [Sale-Price] = @SalePrice,
path = @path
WHERE code = @code

ELSE /* New entry for this Cart. Add a new record */

INSERT INTO CSV
(Name, code, Caption, Price, [Sale-Price],
path,id)
VALUES (@Name, @code, @Caption, @Price, @SalePrice, @path,@id)

SELECT @err = @@error if @err <> 0 return @err
GO
---------------------------
Stanley J. Mroczek

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sumithradevi | last post by:
Hello Friends, I am getting the following error. java.sql.SQLException: ORA-00020: maximum number of processes (100) exceeded I am closing all my resultsets and all my connections in the try...
0
by: Eckard Buchner | last post by:
Hi, we have a query that returns only a few rows, but has a lot of columns in group by clause. In some cases we receive an SQL Exception. Here is the trace setString (1, 20040928001) called...
1
by: Dave | last post by:
Hi, I am trying to trap a SQLException erro in my Global.asax file but I am unable to do it. In my Application_Error code block I have a simple response.write followed by a response.end but...
3
by: Mr.KisS | last post by:
Hello all, I'm working with : WinXP PRO SP1, MS SQL 2005 Express, Visual Web Dev 2005 Express. I have an aspx page which must execute a stored procedure : ______________ try {...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
2
by: Dan Holmes | last post by:
I don't know how to troubleshoot this one. src is after the error. "System.Data.SqlClient.SqlException: XML parsing: line 1, character 698, illegal qualified name character\r\n at...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
1
by: thithi | last post by:
Please help me " System.Data.SqlClient.SqlException: Prepared statement '(@Name varchar(100),@Describes varchar(100),@Money char(10))Upda' expects parameter @Describes, which was not supplied. at...
9
by: freethinker | last post by:
Hi, I have a database class I use to get and drop db connections: public class Database { protected static Connection c; //.... /// .. c = DriverManager.getConnection .... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.