CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2001
    Posts
    193

    can't persist dynamically created table

    Hi Everyone

    I am having a bit of trouble trying to dynamically create tables, then have these persisted to a SQL Server database. I can see that the table is created and updated successfully in the dataset, it has all rows marked with a rowstate = Added, but when I call SqlDataAdapter.Update no new table is created. All other tables in the DB that I am using are updated successfully tho.

    One note, I am dynamically creating these tables as needed, I have a table class that wraps up this type of table, in it's constructor after adding all columns and setting primary key, I Set up a SqlDataApdapter then SqlCommandBuilder.

    This process works well for tables that existed prior to execution, but ...

    Thank you for your time and ideas.
    Patrick Brown

  2. #2
    Join Date
    Feb 2002
    Location
    Spain
    Posts
    148
    Hi:

    The data adapter's update commands (created by the command builder when it's Update Method is called) does not create new tables if they don't exist in the database. They must be created explicitely by you using Transac-SQL code that can be executed using the method ExecuteNonQuery() from the Command object.

    VictorL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured