F
Fir5tSight
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.";
}
}
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? For instance, if
1 is returned, set textMessage.Text as "The file is already in the
system!" However, if 2 is returnd, set textMessage.Text as "The file is
already scanned.".
Thanks!
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.";
}
}
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? For instance, if
1 is returned, set textMessage.Text as "The file is already in the
system!" However, if 2 is returnd, set textMessage.Text as "The file is
already scanned.".
Thanks!