Click here to Skip to main content
16,020,714 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a relatively simple .NET (2.0) application built with VS 2005, that has been running in production for months. The app consist of a webform and a web service which handles all the database retrievals and updates using datasets. Upon launching the page, the app retrieves the requested rows from Oracle tables and displays the data to the user in a textbox, checkbox and drop down list controls. Once the user is finished editing, they click a save button which initiates the actions to re-save the data.

Recently, I attempted to install code changes to this working application. I started by altering one of the production Oracle tables to add a new column. That is as far as I got before the users halted the turnover. Naturally, I restored the table to how it originally looked but now the app abends(?) with the above noted error when the save click event is fired.

I have verified that the table is back to its original format. I have opened and rebuilt both web form solution and web service solution on my local machine, which builds fine but produces the object reference error when run. The error is pointing to the dataset referencing the once-altered table. Does anyone know how the alter table statement I ran in PL/SQL developer affected the production code and how to remedy this situation?
Posted
Updated 25-May-11 4:58am
v2
Comments
OriginalGriff 25-May-11 10:57am    
It's going to be your code, somewhere: post a relevant code fragment (use the "improve question" widget).
What does the Save event do? Do you use "SELECT * FROM" and then use numeric indexes?
Member 7953846 25-May-11 11:03am    
The Save event moves the value of each control to construct the dataset. The error occurs when the control value is null and it attempts to set that column within the data row to DBNull (code below)

private DataRow SetColumnValue2(DataRow row, string columName, System.Web.UI.WebControls.TextBox webControl)
{
if (webControl.Text != "")
{
row[RebinData.TAGS_REBIN_OUTPUT_PARAMS.Columns[columName].Caption] = webControl.Text.Trim();
}
else
{
row[RebinData.TAGS_REBIN_OUTPUT_PARAMS.Columns[columName].Caption] = DBNull.Value;
}

return row;
}
R. Giskard Reventlov 25-May-11 11:07am    
Might be better as:

row[RebinData.TAGS_REBIN_OUTPUT_PARAMS.Columns[columName].Caption] = (string.IsNullOrEmpty(webControl.Text)) ? string.Empty : webControl.Text.Trim();

Is the column set to allow null values?
R. Giskard Reventlov 25-May-11 11:01am    
"I started by altering one of the production Oracle tables to add a new column". Seriously; you started by changing a column in production??? Why would you do that without first making the change in development and making sure it works? Anyway, if the code has not changed then the error is still in the database - are you certain that the table is as it was?
Member 7953846 25-May-11 11:08am    
Yes the change was tested in development. And yes the table is as it was.

1 solution

Run it under debugger and get a line when you have exception. What happens is an attempt to access an non-initialized object of a reference type (null). Alternatively, catch all exceptions and dump Exception.Stack. It will show the code line numbers where the problem is.

If it did not help you to solve the problem, ask a follow-up question but this time show the relevant part of code (exception stack will show you where the problem is) and the exception dump itself.

Again: both!
(Sorry for repeating; so many inquirers show one or the other along; I don't know how they imagine the answer based on such information — I have no idea :-))

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900