Results 1 to 8 of 8

Thread: Save table from DataSet to database

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Asheville, nc
    Posts
    53

    Save table from DataSet to database

    Hi all,

    I am creating a table and populating it in runtime, then I want to save it in database.

    How can I do that using ADO.NET?

    Thanks.
    Victor
    Victor

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Use a dataadapter and specify an update command for it.

    OR,

    Loop through the datatable and build your own command and execute it against the database. (The dataadapter does this internally).

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Asheville, nc
    Posts
    53
    I am assuming that ado.net is pretty smart and I already have all info about the table in DataTable object. So, if I will just loop through columns to create table and loop through rows to insert data, I will be doing just kind of extra work, which is already done.

    I hope that there is some way to just submit entire table (to create table and insert rows in it) by using ADO.NET functions.

    Any ideas?
    Victor

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    What Hellswraith said.
    dataadapter1.Update(dataset1, "myTableName")

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Asheville, nc
    Posts
    53
    There is no table in database yet, it is only in memory in dataset. Nothing to update.

    It maybe would have any meaning, but dataadapter doesn't have connection. To create dataadapter, you need to submit sql query and connection string.
    Victor

  6. #6
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    I guess I'm not sure what you mean. You want to create a table and populate it in code, then add it to a database?

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Asheville, nc
    Posts
    53
    Correct
    Victor

  8. #8
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    I think this question deserves answering.
    (because I'm doing the same thing!)

    What I"m finding is that INSERT and UPDATE SQL commands are becoming my new best friend.
    Merry Christmas

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