Solved

Need a message.

Posted on 2006-10-31
1
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

710 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