mathieu_cupryk
asked on
Need a message.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
Create PROCEDURE [dbo].[RG_sp_DeleteDatePer iod]
(
@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_DatePe riodId". The conflict occurred in database "RG_StudyMatt2610", table "dbo.RF_xDatePeriodInForma t", column 'DatePeriodID'.
private void btnDeleteDatePeriod_Click( object sender, EventArgs e)
{
if (grdDatePeriods.DisplayLay out.Active Row != null)
{
if (grdDatePeriods.Selected.R ows.Count == 1)
{
try
{
Voxco.Data.DatePeriod _dp = Voxco.Data.Manager.DatePer iods.GetOb ject((int) grdDatePer iods.Activ eRow.Cells ["DatePeri odId"].Val ue);
System.Windows.Forms.Dialo gResult Result = System.Windows.Forms.Messa geBox.Show ("Are you sure you want to delete?", "Delete DatePeriod",
System.Windows.Forms.Messa geBoxButto ns.YesNo, System.Windows.Forms.Messa geBoxIcon. Question);
if (Result == System.Windows.Forms.Dialo gResult.Ye s)
{
_dp.Delete(); I need a message here. ************************
RefreshData();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message );
}
}
}
}
public void Delete()
{
VxDbClient _dbClient = SystemDBConnection.CreateS ystemDbCli ent();
DataSet _ds = _dbClient.ExecuteStoredPro c("RG_sp_D eleteDateP eriod",
new VxDbParameter[]
{
new VxDbParameter(VxDbType.Sql , "@iId", Id)
});
}
set QUOTED_IDENTIFIER ON
go
Create PROCEDURE [dbo].[RG_sp_DeleteDatePer
(
@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_DatePe
private void btnDeleteDatePeriod_Click(
{
if (grdDatePeriods.DisplayLay
{
if (grdDatePeriods.Selected.R
{
try
{
Voxco.Data.DatePeriod _dp = Voxco.Data.Manager.DatePer
System.Windows.Forms.Dialo
System.Windows.Forms.Messa
if (Result == System.Windows.Forms.Dialo
{
_dp.Delete(); I need a message here. ************************
RefreshData();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message
}
}
}
}
public void Delete()
{
VxDbClient _dbClient = SystemDBConnection.CreateS
DataSet _ds = _dbClient.ExecuteStoredPro
new VxDbParameter[]
{
new VxDbParameter(VxDbType.Sql
});
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.