As seen from the following code
DataColumn[] keycolumns = new DataColumn[1];
keycolumns[0] = dtable.Columns["formid"];
dtable.PrimaryKey = keycolumns;
dtable = dataSet11.Tables["WCD"];
drow = dtable.Rows.Find(formid);
The
dtable.Columns
is accessed before a
DataTable
is assigned to the variable
dtable
. Hence, the dtable is
null
and accessing a property on
null
object will result in the above stated error. Modifying the code as below by placing
dtable = dataSet1.
at beginning may solve the problem
private void btnsubmit_Click(object sender, EventArgs e)
{
dtable = dataSet11.Tables["WCD"];
DataColumn[] keycolumns = new DataColumn[1];
keycolumns[0] = dtable.Columns["formid"];
dtable.PrimaryKey = keycolumns;
drow = dtable.Rows.Find(formid);