none
DbCommandBuilder can't work properly RRS feed

  • Question

  •         The Table "passport" just have one primary key, and our table include the primary key.

            and the connectionstring is also right.

            and why my "builder" can't generate the right SQL command, and it always generate runtime error ?

     

            private DbProviderFactory myfactory;
            private DbDataAdapter myadapter;
            private DataTable passport;

            //...........................

           //other code.

           // ...........................

            {

                    DbCommandBuilder builder = this.myfactory.CreateCommandBuilder();         
                    builder.DataAdapter = this.myadapter;               
                    this.myadapter.InsertCommand = builder.GetInsertCommand();
                    this.myadapter.DeleteCommand = builder.GetDeleteCommand();
                    this.myadapter.UpdateCommand = builder.GetUpdateCommand();
                    this.myadapter.Update(this.passport);

             }

    Friday, May 30, 2008 2:26 AM

All replies

  • Do you get any error? What is your SQL statement?  In some cases CommandBuilder is not able to generate statements because there is not enough information to build them based on provided query, or query is too complicated. In this case you need to create all action SQL statements using your own code.

     

    Friday, May 30, 2008 9:56 AM
    Moderator