Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SqlCommandBuilder class
Message
 
 
To
14/04/2014 13:57:47
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01598513
Message ID:
01598619
Views:
25
>Try not setting the adapter.UpdateCommand. See remarks section under http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand%28v=vs.110%29.aspx and the fifth paragraph at http://msdn.microsoft.com/en-us/library/tf579hcz%28v=vs.110%29.aspx for reasons why it shouldn't be set.

If I am not setting it myself, it remains NULL. Do you see what is missing in my code? I populate the adapter by passing SqlCommand.

I moved creating of the builder into the UpdateRows() method, but it was originally in the Populate method and still all the adapter's commands were null.

Adapter is defined as private property of the class.

This is how the class is defined:
 public class DataTableHelper
    {
        public Int32 RecordCount
        {
            get
            {
                if (null == table)
                    return 0;
                else
                    return table.Rows.Count;
            }
            //private set { } - no need for set as this property makes sense as get only
        }

        public DataTable table = null;
        SqlDataAdapter adapter = null; 

        //=====================================================================================================================
        public DataTableHelper()
        {
        }

        //=====================================================================================================================
        public DataTableHelper(SqlCommand toSqlCommand)
        { ProcessDataTable(toSqlCommand); }

        //=====================================================================================================================
        public Boolean Populate(SqlCommand toSqlCommand)
        { return ProcessDataTable(toSqlCommand); }
I don't see why the UpdateCommand (and other commands) remain null until I explicitly request them.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform