finance_teacher
asked on
C# -- DataGridView -- TableAdapter COUNT ?
The below two "WORKS" sections works.
How can I change the below "FAILS"
section to have something like
a ".Results > 0" ?
** attached shows that
.Results is not valid
-------------------------- ---------- ---------- ----
WORKS #1
if (vAD_PREPRESS_ID > 0 && Convert.ToBoolean(accountD etailMaint enanceData GridView.R ows[i].Cel ls["PREPRE SS"].Value ) == false)
{
this.accountDetailMaintena nceTableAd apter.Dele te_AD_Reco rd(vAD_PRE PRESS_ID);
}
-------------------------- ---------- ---------- ----
WORKS #2
.Has_Designer_Records
SELECT count(im.PDESIGNER)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
-------------------------- ---------- ---------- ----
FAILS
if (vAD_PREPRESS_ID > 0 && Convert.ToBoolean(accountD etailMaint enanceData GridView.R ows[i].Cel ls["PREPRE SS"].Value ) == false)
{
if (this.accountDetailMainten anceTableA dapter.Has _Designer_ Records(vA D_DESIGNER _ID).Resul ts > 0)
{
MessageBox.Show("GML_ITEMM STR PDESIGNER record exists, cannot delete " + vAD_DESIGNER_ID);
}
else
{
this.accountDetailMaintena nceTableAd apter.Dele te_AD_Reco rd(vAD_PRE PRESS_ID);
}
}
0001.jpg
How can I change the below "FAILS"
section to have something like
a ".Results > 0" ?
** attached shows that
.Results is not valid
--------------------------
WORKS #1
if (vAD_PREPRESS_ID > 0 && Convert.ToBoolean(accountD
{
this.accountDetailMaintena
}
--------------------------
WORKS #2
.Has_Designer_Records
SELECT count(im.PDESIGNER)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
--------------------------
FAILS
if (vAD_PREPRESS_ID > 0 && Convert.ToBoolean(accountD
{
if (this.accountDetailMainten
{
MessageBox.Show("GML_ITEMM
}
else
{
this.accountDetailMaintena
}
}
0001.jpg
slight modification
if (this.accountDetailMaintenanceTableAdapter.Has_Designer_Records(vAD_DESIGNER_ID).HasValue)
{
MessageBox.Show("GML_ITEMMSTR PDESIGNER record exists, cannot delete " + vAD_DESIGNER_ID);
}
else
{
this.accountDetailMaintenanceTableAdapter.Delete_AD_Record(vAD_PREPRESS_ID);
}
ASKER
Still fails
Example
1. attached displays
2. uncheck 10163 & 10170
3. click "Save"
4. below 10163 results display "2",
MessageBox.Show runs
5. below 10170 results display "0",
MessageBox.Show runs, but should
not since results are NOT > 0
-------------------------- ---------- ---
SELECT count(im.PDESIGNER)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
-------------------------- ---------- ---
0001.jpg
Example
1. attached displays
2. uncheck 10163 & 10170
3. click "Save"
4. below 10163 results display "2",
MessageBox.Show runs
5. below 10170 results display "0",
MessageBox.Show runs, but should
not since results are NOT > 0
--------------------------
SELECT count(im.PDESIGNER)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
--------------------------
0001.jpg
Hi finance_teacher,
Change your WORKS #2 by adding ISNULL checking:
.Has_Designer_Records
SELECT ISNULL(count(im.PDESIGNER) , 0)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
Then you can use the following line:
if (this.accountDetailMainten anceTableA dapter.Has _Designer_ Records(vA D_DESIGNER _ID).Value > 0)
Change your WORKS #2 by adding ISNULL checking:
.Has_Designer_Records
SELECT ISNULL(count(im.PDESIGNER)
FROM GML_ITEMMSTR im
Where im.PDESIGNER in
(
SELECT
ad.AM_CID
FROM GML_ACCTDETL ad
Where ad.ID = :vAD_DESIGNER_ID
)
Then you can use the following line:
if (this.accountDetailMainten
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The below seems to work without
this.accountDetailMaintena nceTableAd apter.Has_ Designer_R ecords(vAD _DESIGNER_ ID).HasVal ue
Is the above line really needed ?
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -
if (vAD_DESIGNER_ID > 0 && Convert.ToBoolean(accountD etailMaint enanceData GridView.R ows[i].Cel ls["DESIGN ER"].Value ) == false)
{
if (this.accountDetailMainten anceTableA dapter.Has _Designer_ Records(vA D_DESIGNER _ID).Value > 0)
{
MessageBox.Show("GML_ITEMM STR PDESIGNER record exists, cannot delete " + vAD_DESIGNER_ID);
}
else
{
this.accountDetailMaintena nceTableAd apter.Dele te_AD_Reco rd(vAD_DES IGNER_ID);
}
}
this.accountDetailMaintena
Is the above line really needed ?
--------------------------
if (vAD_DESIGNER_ID > 0 && Convert.ToBoolean(accountD
{
if (this.accountDetailMainten
{
MessageBox.Show("GML_ITEMM
}
else
{
this.accountDetailMaintena
}
}
Hi finance_teacher,
It will not be needed as long as the .Value will never contain NULL.
It will not be needed as long as the .Value will never contain NULL.
Open in new window