Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum "Export-DataTableToSQLiteDB : DataTable already belongs to another DataSet."
    • Sign In

    • State Verified Answer
    • Replies 4 replies
    • Subscribers 67 subscribers
    • Views 797 views
    • Users 0 members are here
    • pspw_pwdm
    • powershell
    • pspw_dab
    • DataTable

    "Export-DataTableToSQLiteDB : DataTable already belongs to another DataSet."

    Matt Blumenfeld
    Offline Matt Blumenfeld over 2 years ago

    I'm using PWPS_PWDM (which works pretty well) to gather info from Deliverables Management. With some assistance getting set up, I have been able to get a Submittals information dataset sorted into datatables, and from there into Excel. I'd like to just write the tables straight into a SQLite database, using the Export-DataTableToSQLiteDB cmdlet, but when I try to run the command I get an error message: "Export-DataTableToSQLiteDB : DataTable already belongs to another DataSet."

    I think I'm missing something obvious here. Can anyone tell me what's going on?

    • Sign in to reply
    • Cancel

    Top Replies

    • Zachary Kerr
      Offline Zachary Kerr Sun, Jun 20 2021 8:48 PM in reply to Matt Blumenfeld +1 verified
      Hey Matt, glad you got it working. A simple solution is to just copy the whole data table. Something like this: foreach ($table in $Dataset.Tables) { $table_copy = $table.Copy() Do-Whatever -InputTable…
    Parents
    • Matt Blumenfeld
      0 Offline Matt Blumenfeld Sun, Jun 20 2021 7:38 PM

      It appears that the solution was to go away for a little while and then come back with a fresh mindset. Slight smile

      Upon returning I had a "Duh" moment and created a new datatable with the same columns as the source one, copied the rows into the new datatable and then I had one that didn't "already belong to a dataset". 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Zachary Kerr
      +1 Offline Zachary Kerr Sun, Jun 20 2021 8:48 PM in reply to Matt Blumenfeld

      Hey Matt, glad you got it working.
      A simple solution is to just copy the whole data table. Something like this:

      foreach ($table in $Dataset.Tables)
      {
          $table_copy = $table.Copy()
          Do-Whatever -InputTable $table_copy
      }


      That will save you having to rebuild the tables and populate row by row.
      Hope this helps.

      Answer Verified By: Matt Blumenfeld 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • Matt Blumenfeld
      0 Offline Matt Blumenfeld Mon, Jun 21 2021 1:13 PM in reply to Zachary Kerr

      Thanks, Zachary. That's even easier. 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Matt Blumenfeld
      0 Offline Matt Blumenfeld Mon, Jun 21 2021 1:13 PM in reply to Zachary Kerr

      Thanks, Zachary. That's even easier. 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    No Data

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies