Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Trying to Work Around Bug in OleDbCommandBuilder for spaces in table name

Back to Forum: Tech Off
  • User profile image

    When there is a space in the table name, and update or insertinto command generates a sysntax error on update, even if the SQL syntax for filling the table bracketed the table name, which works for for the fill.  If the tablename has no spaces all is well.

    DataTable DT = newDataTable();

    OleDbDataAdapterDataAdapter = newOleDbDataAdapter("Select * from [MY TABLE SPACES]",DataBaseConnection);


    // do something to update a field or add a record

    UpdateBuilder = new OleDbCommandBuilder(DataAdapter);

    DataAdapter.Update(DT);  // generates exception

    The CommandText for the dbCommand of the OleDbCommandBuilder is missing the brakcets.

    I have tried to work around this by reading UpdateBuilder.GetUpdateCommand().CommandText inserting the brackets and replacing the CommandText.  However, even though it compiles and there is no runtime error in the CommandText assignment, it does not replace the CommandText.

    Yes, I know having spaces in a table name is not good DB design, but I am not creating the tables, they are being created in access, and access allows users to create tablenames with spaces in the name.

    Any suggestions?


  • User profile image

    @RayQuay: Manually create the insert/update/delete commands? There's not much else you can do.

    DataAdapter.UpdateCommand = blah blah

    DataAdapter.InsertCommand = blah blah

    et cetera

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.