Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need a message.

Posted on 2006-10-31
1
Medium Priority
?
177 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 1500 total points
ID: 17852882
You can just change the message: show your own text instead of the ex.Message.
0

Featured Post

Technology Partners: 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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 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