R
Randy Smith
Hi,
I've got some weird behavior happening within one of the datamappers. It
all has to do with inserting a new row, and returning the Id of the row
being entered.
Here is what the code looks like that is getting "Object reference not set
to an instance ..." run-time error:
string ateId = cm.ExecuteScalar().ToString(); ß------------
this line crashes
None of the parameters are null, nor do they appear to have any illegal data
inside of them. The above code inserts a row into the AuditTrailEntry
table.
On the other hand, this code inserts a new jobStep row, and doesn't cause
any errors:
if (storedProcedure == "updateJobStep") //use this if update
cm.ExecuteNonQuery(); // no return value needed
else
{
string jobStepId = cm.ExecuteScalar().ToString(); //insert new
jobStep, get id of new row
js.Id = Convert.ToInt16(jobStepId);
}
Does anyone see a problem with this code, or know why it doesn't work?
TIA, Randy
I've got some weird behavior happening within one of the datamappers. It
all has to do with inserting a new row, and returning the Id of the row
being entered.
Here is what the code looks like that is getting "Object reference not set
to an instance ..." run-time error:
string ateId = cm.ExecuteScalar().ToString(); ß------------
this line crashes
None of the parameters are null, nor do they appear to have any illegal data
inside of them. The above code inserts a row into the AuditTrailEntry
table.
On the other hand, this code inserts a new jobStep row, and doesn't cause
any errors:
if (storedProcedure == "updateJobStep") //use this if update
cm.ExecuteNonQuery(); // no return value needed
else
{
string jobStepId = cm.ExecuteScalar().ToString(); //insert new
jobStep, get id of new row
js.Id = Convert.ToInt16(jobStepId);
}
Does anyone see a problem with this code, or know why it doesn't work?
TIA, Randy