Solved

Need a message.

Posted on 2006-10-31
1
171 Views
Last Modified: 2010-04-16
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

Create PROCEDURE [dbo].[RG_sp_DeleteDatePeriod]
(
      @iId int
)
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
      DELETE FROM RF_DatePeriod WHERE @iId NOT IN (SELECT DatePeriodId FROM RF_xDatePeriodInFormat)

END

I need to display a message say Cannot delete DatePeriodId that belongs to ReportFormat


Msg 547, Level 16, State 0, Procedure RG_sp_DeleteDatePeriod, Line 11
The DELETE statement conflicted with the REFERENCE constraint "FK_xPeriodInFormat_DatePeriodId". The conflict occurred in database "RG_StudyMatt2610", table "dbo.RF_xDatePeriodInFormat", column 'DatePeriodID'.


private void btnDeleteDatePeriod_Click(object sender, EventArgs e)
        {
            if (grdDatePeriods.DisplayLayout.ActiveRow != null)
            {
                if (grdDatePeriods.Selected.Rows.Count == 1)
                {
                    try
                    {
                        Voxco.Data.DatePeriod _dp = Voxco.Data.Manager.DatePeriods.GetObject((int)grdDatePeriods.ActiveRow.Cells["DatePeriodId"].Value);
                        System.Windows.Forms.DialogResult Result = System.Windows.Forms.MessageBox.Show("Are you sure you want to delete?", "Delete DatePeriod",
                        System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
                        if (Result == System.Windows.Forms.DialogResult.Yes)
                        {
                            _dp.Delete();  I need a message here. ************************
                            RefreshData();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }


                }
            }
        }

public void Delete()
        {
            VxDbClient _dbClient = SystemDBConnection.CreateSystemDbClient();
            DataSet _ds = _dbClient.ExecuteStoredProc("RG_sp_DeleteDatePeriod",
                new VxDbParameter[]
                {
                    new VxDbParameter(VxDbType.Sql, "@iId", Id)              
 
                });

        }
0
Comment
Question by:mathieu_cupryk
1 Comment
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 17852882
You can just change the message: show your own text instead of the ex.Message.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question