Create a new record in the opened form
We can insert the record by using the below code. This is
the normal procedure, creates new table buffer, assign values and call insert
method.
void clicked()
{
Hari_ExamResult examResults;
examResults.StudentName
= "Zyx";
examResults.Standard = "Sixth";
examResults.ExamResult = "Pass";
examResults.RollNo
= 1004;
examResults.insert();
super();
}
Our scenario is how to add a new record when form opens. If
you use the above code in this scenario we should call the below code after the
insert method before the super method call.
Hari_ExamResult_ds.research();
Hari_ExamResult_ds.refresh();
Note: Here, form datasource reread method won’t work, because when
we call the reread method, it won’t call the form datasource executequery
method. But, if we call the research method, it will call the form datasource
executequery method.
The best practice for this scenario is calling the form
datasource create method.
void clicked()
{
Hari_ExamResult_ds.create();
Hari_ExamResult.StudentName = "Zyx";
Hari_ExamResult.Standard = "Sixth";
Hari_ExamResult.ExamResult = "Pass";
Hari_ExamResult.RollNo = 1004;
Hari_ExamResult.insert();
Hari_ExamResult_ds.reread();
Hari_ExamResult_ds.refresh();
super();
}
Please use the form datasource create method to create the records when form opens.
No comments :
Post a Comment