473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Handling of different return number in stored procedure

Hi All,

I have a C#.NET code as follows:

private void ScanInput_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
try
{
Row lRow = this.Connection.InsertScannedFile(ID);

}
catch (Exception /*lException*/)
{
textMessage.Text = "The ID value cannot be found in the system.";
textReportPackage.Clear();
textReportInstanceID.Clear();
textAccountID.Clear();
textAddress.Clear();

groupDetails.Visible = false;

this.PlaySound(this.MainForm.BadScanPath);
}
}

void InsertScannedFile (int id)
{
this.ExecuteStoredProcedure(lReturn,
Constants.StoredProcedures.SPInsertScannedFile,
new SqlParameter("@ID",id));

return lReturn.SPInsertScannedFile[0];
}

// The stored procedure is like the follows:

CREATE PROCEDURE SPInsertScannedFile
@ID DTObjectID,

AS

IF EXISTS
(
SELECT
DistributionID
FROM
table1
WHERE
DistributionID = @ID

)
BEGIN
RAISERROR ('The file is already in the system!',16,1)
RETURN 1
END
IF NOT EXISTS
(
SELECT
FileID
FROM
table2
WHERE
FileID = @ID

)
BEGIN
RAISERROR ('The file is already scanned.',16,1)
RETURN 2
END
-- insert a new record
INSERT INTO
table2
(
ID,
Time_recorde_inserted
)
SELECT
@ID,
getdate()

-- return the details
SELECT
-- some field names
FROM
table1 INNER JOIN table2 -- etc.
WHERE
table1.DistributionID = @ID
RETURN 0
GO

--------------------------------------------------------------------------------
Could anyone advise me how to handle different return code (1 or 2)
differently from the stored procedure in the C# code?

Thanks!

Dec 15 '06 #1
0 960

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

Similar topics

1
by: Jon LaRosa | last post by:
Hi all - I have a web application and I want to be able to do some basic error handling. For example, here is one error I would like to catch and display in a useful way for the user: ...
2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
9
by: dtwilliams | last post by:
OK, i'm trying to do some error checking on stored procedures and am following the advise in Erland Sommarskog's 'Implementing Error Handling with Stored Procedures' document. Can anybody help...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
5
by: Jurgen Defurne | last post by:
I am currently designing an application which should be accessible from different interfaces. For this I like to be using stored procedures to process the contents of form submissions and dialog...
9
by: serge | last post by:
/* Subject: How to build a procedure that returns different numbers of columns as a result based on a parameter. You can copy/paste this whole post in SQL Query Analyzer or Management Studio...
5
by: Fir5tSight | last post by:
Hi All, I have a C#.NET code as follows: private void ScanInput_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { try { Row lRow = this.Connection.InsertScannedFile(ID);
1
by: pob | last post by:
>From a form I have some code that calls 4 modules frmMain 1 mod 2 mod 3 mod 4 mod If mod 1 experiences an error the error handling works fine within mod 1 and writes out the error to a...
4
by: barmatt80 | last post by:
I am stumped on the error reporting with sql server. I was told i need to return @SQLCode(code showing if successful or not) and @ErrMsg(and the message returned). I am clueless on this. I...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.