Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem saving with custom data access class
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00940287
Message ID:
00940352
Views:
17
Here it is. Thanks!

In codebehind of web page:
private void btnSave_Click(object sender, System.EventArgs e)
{	
   DataSet ds = (DataSet)Session["dsOrganizationType"];
   
   // Kludge/Test code:
   this.oOrganizationType.MyUpdate(ds, this.oOrganizationType.TableName);
   Response.Redirect("OrganizationTypeSelect.aspx");
   
   // Original code:
   //if (this.Save(this.oOrganizationType, ds, this.oOrganizationType.TableName) == mmSaveDataResult.RulesPassed)
   //{
   //	Response.Redirect("OrganizationTypeSelect.aspx");
   //}
}
Temporary test function in business object:
public void MyUpdate(DataSet ds, string tableName)
{
   mmDataAccessBase dao;
   dao = this.GetDataAccessObject();
   
   if (this.SaveDataSet(ds, this.TableName) == OakLeaf.MM.Main.Business.mmSaveDataResult.RulesPassed)
   {
      return;
   }
   return;
}
I put a HookPreSave in for debugging:
protected override bool HookPreSave(DataTable dt)
{
   mmDataAccessBase dao;
   dao = this.GetDataAccessObject();
   
   return base.HookPreSave (dt);
}
The error below occurs upon exit from HookPreSave.
Server Error in '/ITAdminWeb' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


Line 154:			dao = this.GetDataAccessObject();
Line 155:
Line 156:			if (this.SaveDataSet(ds, this.TableName) == OakLeaf.MM.Main.Business.mmSaveDataResult.RulesPassed)
Line 157:			{
Line 158:				return;
 

Source File: c:\projects\visualstudionetprojects\itadminweb business\organizationtype.cs    Line: 156 

Stack Trace: 


[NullReferenceException: Object reference not set to an instance of an object.]
   OakLeaf.MM.Main.Data.mmDataAccessSql.SaveDataSet(DataSet ds, String tableName, String primaryKeyName, Boolean retrieveAutoIncrementPK, IDbDataAdapter dbAdapter)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey, IDbDataAdapter dbAdapter)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName)
   Brickmill.ITAdminWeb.Business.OrganizationType.MyUpdate(DataSet ds, String tableName) in c:\projects\visualstudionetprojects\itadminweb business\organizationtype.cs:156
   Brickmill.ITAdminWeb.OrganizationTypeMaint.btnSave_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\itadminweb\organizationtypemaint.aspx.cs:103
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573 
For good measure, here is the InitializeComponent from OrganizationTypeDataAccessSql:
public class OrganizationTypeDataAccessSql : mmDataAccessSql
{
   private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
   private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
   private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
   private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
   private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
   
   private void InitializeComponent()
   {
      this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
      this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
      this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
      this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
      this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
      // 
      // sqlDataAdapter1
      // 
      this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
      this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
      this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
      this.sqlDataAdapter1.TableMappings.AddRange(
         new System.Data.Common.DataTableMapping[] 
         {
            new System.Data.Common.DataTableMapping("Table", "tblOrganizationType", new System.Data.Common.DataColumnMapping[] 
            {
               new System.Data.Common.DataColumnMapping("iOrganizationTypePK", "iOrganizationTypePK"),
               new System.Data.Common.DataColumnMapping("cOrganizationTypeCode", "cOrganizationTypeCode"),
               new System.Data.Common.DataColumnMapping("vOrganizationType", "vOrganizationType"),
               new System.Data.Common.DataColumnMapping("iMayHaveUsers", "iMayHaveUsers")
            })
         }
      );
      
      this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
      // 
      // sqlSelectCommand1
      // 
      this.sqlSelectCommand1.CommandText = "[dbo.lp_tblOrganizationType_get_data]";
      this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
      this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iPK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

      this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iReturnCode", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vErrMsg", System.Data.SqlDbType.VarChar, 230, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

      // 
      // sqlInsertCommand1
      // 
      this.sqlInsertCommand1.CommandText = "[dbo.lp_tblOrganizationType_insert]";
      this.sqlInsertCommand1.CommandType = System.Data.CommandType.StoredProcedure;
      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@cOrganizationTypeCode", System.Data.SqlDbType.VarChar, 10, "cOrganizationTypeCode"));
      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vOrganizationType", System.Data.SqlDbType.VarChar, 50, "vOrganizationType"));
      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iMayHaveUsers", System.Data.SqlDbType.TinyInt, 1, "iMayHaveUsers"));

      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iReturnCode", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vErrMsg", System.Data.SqlDbType.VarChar, 230, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

      // 
      // sqlUpdateCommand1
      // 
      this.sqlUpdateCommand1.CommandText = "[dbo.lp_tblOrganizationType_update]";
      this.sqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure;
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iOrganizationTypePK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iOrganizationTypePK", System.Data.DataRowVersion.Original, null));
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@cOrganizationTypeCode", System.Data.SqlDbType.VarChar, 10, "cOrganizationTypeCode"));
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vOrganizationType", System.Data.SqlDbType.VarChar, 50, "vOrganizationType"));
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iMayHaveUsers", System.Data.SqlDbType.TinyInt, 1, "iMayHaveUsers"));

      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iReturnCode", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vErrMsg", System.Data.SqlDbType.VarChar, 230, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

      // 
      // sqlDeleteCommand1
      // 
      this.sqlDeleteCommand1.CommandText = "[dbo.lp_tblOrganizationType_delete]";
      this.sqlDeleteCommand1.CommandType = System.Data.CommandType.StoredProcedure;
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iOrganizationTypePK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iOrganizationTypePK", System.Data.DataRowVersion.Original, null));
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_cOrganizationTypeCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "cOrganizationTypeCode", System.Data.DataRowVersion.Original, null));
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iMayHaveUsers", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iMayHaveUsers", System.Data.DataRowVersion.Original, null));
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_vOrganizationType", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "vOrganizationType", System.Data.DataRowVersion.Original, null));

      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iReturnCode", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
      this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@vErrMsg", System.Data.SqlDbType.VarChar, 230, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

   }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform