I'm trying to use a DataSet to maintain some rows for a table, and when I've finished my changes, send all changes to the database using a SqlDataAdapter.
I find if there are no rows in the table in the database then I am getting a 'Object reference not set to an instance of an object' when I try to access the table in the Dataset.
Is there a way to work with a Dataset like this ie. I start off with an empty table and I wish to add rows, to access the structure of the table rows, build rows, then add them and do the update on the SQLDataAdapter.
Here is my code: protected SqlDataAdapter memberDA = new SqlDataAdapter();
protected DataSet memberDS
if (ViewState["memberDS"] != null)
return new DataSet();
ViewState["memberDS"] = value;
protected SqlDataAdapter getDataAdapterForMembers()
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["SiteDBConn"].ConnectionString;
memberDA = new SqlDataAdapter("usp_GetMembers", conn);
memberDA.SelectCommand.CommandType = CommandType.Stored
View Complete Post