Isai
(Isaiselvan S)
May 31, 2019, 11:17am
1
Here, I added sample code for trying to delete the child records,
for(int i=0; i<= dtQuotes.Rows.Count-1 ; i++)
//if(dtQuotes.Rows.Count > 0)
{
if (Convert.ToString(dtQuotes.Rows[i][“FiledName”].ToString())!= “”)
//if(ChldPhs == dtQuotes.Rows[i]["FiledName"].ToString())
{
//dtQuotes.Rows[i]["FiledName"] = "";
dtQuotes.Rows[i].Delete();
oTrans.Update();
/*foreach (DataRow newrow in dtQuotes.Rows)
{
if(newrow["RowMod"].ToString() == "" && newrow["FiledName"].ToString() != null)
{
newrow.Delete();
}
}*/
//oTrans.Refresh();
//oTrans.Delete();
}
}
}
ckrusen
(Calvin Krusen)
June 1, 2019, 4:26pm
2
["FieldName"]
should reference the name of a field in the dataset.
For example
if (Convert.ToString(dtQuotes.Rows[i]["PartNum"].ToString())!= "")
Edit
The above mentioned error caught my eye, and I didn’t check the logic of the rest of tge functions
Isai
(Isaiselvan S)
June 3, 2019, 9:28am
3
thanks for you response.
the below code is i used and try to delete the Child Record to parent record. But its not working where i made a mistake.
if(tProjID != "" && tPhsID != "" && tPrntPhse =="")
{
DynamicQueryAdapter adapterDynamicQueryQuote = new DynamicQueryAdapter(oTrans);
adapterDynamicQueryQuote.BOConnect();
bool results = adapterDynamicQueryQuote.GetDashboardQuery("test0123");
if(results)
{
QueryExecutionDataSet ObQEd= new QueryExecutionDataSet();
DataRow drReqNo = ObQEd.Tables["ExecutionParameter"].NewRow();
drReqNo["ParameterID"] = "PojID";
drReqNo["ParameterValue"] = ProjID.Value.ToString();
drReqNo["ValueType"] = "character";
drReqNo["IsEmpty"] = false;
drReqNo["RowMod"] = "A";
ObQEd.Tables["ExecutionParameter"].Rows.Add(drReqNo);
DataRow drDocType = ObQEd.Tables["ExecutionParameter"].NewRow();
drDocType["ParameterID"] = "PhseID";
drDocType["ParameterValue"] = PhsID.Value.ToString();
drDocType["ValueType"] = "character";
drDocType["IsEmpty"] = false;
drDocType["RowMod"] = "A";
ObQEd.Tables["ExecutionParameter"].Rows.Add(drDocType);
adapterDynamicQueryQuote.ExecuteDashboardParameterized(adapterDynamicQueryQuote.RuntimeQuery,ObQEd);
DataTable dtQuotes = new DataTable();
dtQuotes= adapterDynamicQueryQuote.QueryResults.Tables[0];
int n = dtQuotes.Rows.Count-1;
for(int i=0; i<= dtQuotes.Rows.Count-1 ; i++)
//if(dtQuotes.Rows.Count > 0)
{
//ChldPhs = dtQuotes.Rows[i]["ProjPhase_ParentPhase"].ToString();
if (Convert.ToString(dtQuotes.Rows[i]["ProjPhase_ParentPhase"].ToString())!= "")
//if(ChldPhs == dtQuotes.Rows[i]["ProjPhase_ParentPhase"].ToString())
{
//dtQuotes.Rows[i]["ProjPhase_ParentPhase"] = "";
//dtQuotes.Rows[i].Delete();
//oTrans.Update();
foreach (DataRow dr in dtQuotes.Rows)
{
if(dr["ProjPhase_ParentPhase"].ToString() != null)
{
dr.Delete();
oTrans.Update();
}
}
}
else if(tProjID != "" && tPhsID != "" && tPrntPhse =="")
{
oTrans.Delete();
}
}
}
}
dhewi
(Daryl Hewison)
June 3, 2019, 10:19am
4
This looks dangerous to me - deletion is always something to be wary of. What are you trying to do here? What’s the overall goal?
Isai
(Isaiselvan S)
June 4, 2019, 11:52am
5
Hi Dary,
If they entered the wrong entry in Project Entry. I’m going to delete the WBSPhase from the child to Parent record. Then i’ve to check the if the Child is mapped with any job’s that values are replaces only WBS Pahse. So, that am going to delete the record in Project Entry. Kindly help on this.
dhewi
(Daryl Hewison)
June 4, 2019, 12:02pm
6
And where are you doing it? It makes quite a lot of difference where the code is running.
If you MUST delete, the safest way is to use the Business Object for the relevant data, because that way there are built-in checks that stop the disastrous types of deletion. I don’t recognise the way you seem to be attempting. It is possible to delete via dynamic query, but simply deleting the results doesn’t do that.