locked
Custom BLL with dynamic number of columns; how to define update method? RRS feed

  • Question

  • User1835401063 posted

    Hello

    I have this custom BLL:

        [System.ComponentModel.DataObject]
        public class BLL
        {
            public BLL()
            {
    
            }
    
            [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
            public DataTable select()
            {
                DataTable D = new DataTable();
                D.Columns.Add("Column1", typeof(string));
                
                object[] Row = new object[NumberofColumns];
    
                D.Rows.Add(Row);
                return D;
            }
    
            [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
            public bool Update(List of parameters)
            {
                return true;
            }
        }
    


    Select part is not a problem, I return my custom table. But how can I define list of parameters for update method while number of columns is dynamic?

    Thanks

    Friday, December 7, 2012 3:59 PM

Answers

  • User3866881 posted

    Does SqlDataAdapter manipulate my in memory table? There is no SQL Server backside. And, does SqlDataAdapter connect to data view controls like Gridview?

    No. SQLDataAdapter will only fetch data contents from db's table and fill into a DataTable.

    If you only wanna use a memory-based DataTable, just please define a static DataTable or a DataTable that is stored in a ViewState and you can always use that.

    I don't know if there may be a more standard way? 

    For a memory-based DataTable, that's enough;)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 8, 2012 8:43 PM

All replies

  • User3866881 posted

    Hello,

    As far as I see, since your DataTable is memory-based. And your dynamic DataTable can be from different kind of table in your database. So you have to reject the ObjectDataSource (because any DataSource can be applied to a fixed structure db). You have to use SqlDataAdapter.Fill method for a DataTable, and then use SqlCommandBuilder to build automatically CRUD and if there's anything changed for any row inside the DataRow, just directly call adapter.Update(DataTable instance);


     

    Saturday, December 8, 2012 5:09 AM
  • User1835401063 posted

    Thanks

    I must put some time to explore it in depth, I'm not sure if I got your meaning or not, Does SqlDataAdapter manipulate my in memory table? There is no SQL Server backside. And, does SqlDataAdapter connect to data view controls like Gridview?

    Byh the way I used DetailsView_ItemUpdating method of detailsview and it works for my case for updating my im memory table. I don't know if there may be a more standard way? 


    Saturday, December 8, 2012 3:00 PM
  • User3866881 posted

    Does SqlDataAdapter manipulate my in memory table? There is no SQL Server backside. And, does SqlDataAdapter connect to data view controls like Gridview?

    No. SQLDataAdapter will only fetch data contents from db's table and fill into a DataTable.

    If you only wanna use a memory-based DataTable, just please define a static DataTable or a DataTable that is stored in a ViewState and you can always use that.

    I don't know if there may be a more standard way? 

    For a memory-based DataTable, that's enough;)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 8, 2012 8:43 PM