Solved

Need a message.

Posted on 2006-10-31
1
169 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now