Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Dataset save as new .mdb

Dataset save as new .mdb

Scheduled Pinned Locked Moved C#
tutorial
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S shoubi

    Hi Troll Thank you for replying. I have a datset filled with a table, and i need to export this table as a new access database.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #5

    shoubi wrote:

    I have a datset filled with a table, and i need to export this table as a new access database.

    Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)

    I are Troll :suss:

    S 2 Replies Last reply
    0
    • L Lost User

      shoubi wrote:

      I have a datset filled with a table, and i need to export this table as a new access database.

      Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)

      I are Troll :suss:

      S Offline
      S Offline
      shoubi
      wrote on last edited by
      #6

      Hi Troll Thank you! i manage to do it! however i need to check for duplication of records. I have a dataset to insert into the database. How do i check for duplicate records. let say if the record has existed in the database then it will not be inserted. Thanks for reading! zheng

      L 1 Reply Last reply
      0
      • S shoubi

        Hi Troll Thank you! i manage to do it! however i need to check for duplication of records. I have a dataset to insert into the database. How do i check for duplicate records. let say if the record has existed in the database then it will not be inserted. Thanks for reading! zheng

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #7

        shoubi wrote:

        Thank you! i manage to do it!

        My pleasure, and good job :)

        shoubi wrote:

        let say if the record has existed in the database then it will not be inserted.

        That's the job of the Primary Key[^]. As an example, a single person would be uniquely identified by his/her social security number, so we could make that our primary key. That would make the database guard against duplicates in that table, based on the contents of the "social security number"-field. Another way to prevent duplicates would be using the UNIQUE[^]-constraint.

        I are Troll :suss:

        1 Reply Last reply
        0
        • L Lost User

          shoubi wrote:

          I have a datset filled with a table, and i need to export this table as a new access database.

          Start by creating an empty Access database. Then try creating an OleDb connection as suggested, and write the dataset to the database. You can always get help with specific questions here if you get stuck midway :)

          I are Troll :suss:

          S Offline
          S Offline
          shoubi
          wrote on last edited by
          #8

          hi troll how to transfer values from one datatable to another datatable. For example there are 2 datatables Table A and Table B. If then column name in Table A is the same as Table B then all the values of that column will go into Table B of the same column name. Hope you understand me. Thank you zheng

          L 1 Reply Last reply
          0
          • S shoubi

            hi troll how to transfer values from one datatable to another datatable. For example there are 2 datatables Table A and Table B. If then column name in Table A is the same as Table B then all the values of that column will go into Table B of the same column name. Hope you understand me. Thank you zheng

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #9

            Hi :) The easiest way to do so would be in Sql, combining a SELECT with an INSERT statement. The code below should work with the AdventureWorks database;

            INSERT INTO Person.Contact (
            FirstName,
            LastName,
            Title,
            PasswordHash,
            PasswordSalt)
            SELECT FirstName,
            LastName,
            Title,
            PasswordHash,
            PasswordSalt
            FROM Person.Contact

            Hope this helps :)

            I are Troll :suss:

            S 1 Reply Last reply
            0
            • L Lost User

              Hi :) The easiest way to do so would be in Sql, combining a SELECT with an INSERT statement. The code below should work with the AdventureWorks database;

              INSERT INTO Person.Contact (
              FirstName,
              LastName,
              Title,
              PasswordHash,
              PasswordSalt)
              SELECT FirstName,
              LastName,
              Title,
              PasswordHash,
              PasswordSalt
              FROM Person.Contact

              Hope this helps :)

              I are Troll :suss:

              S Offline
              S Offline
              shoubi
              wrote on last edited by
              #10

              hi troll thank you for replying:) i would like to copy values of a column in the dataset to another column in another dataset. the condition is: if the both column name is the same. thank you!

              L 1 Reply Last reply
              0
              • S shoubi

                hi troll thank you for replying:) i would like to copy values of a column in the dataset to another column in another dataset. the condition is: if the both column name is the same. thank you!

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                shoubi wrote:

                the condition is: if the both column name is the same

                ..and do you know how to check that?

                I are Troll :suss:

                S 1 Reply Last reply
                0
                • L Lost User

                  shoubi wrote:

                  the condition is: if the both column name is the same

                  ..and do you know how to check that?

                  I are Troll :suss:

                  S Offline
                  S Offline
                  shoubi
                  wrote on last edited by
                  #12

                  hi troll thank you for your help... i managed to do it! thank you! zheng

                  L 1 Reply Last reply
                  0
                  • S shoubi

                    hi troll thank you for your help... i managed to do it! thank you! zheng

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    shoubi wrote:

                    thank you for your help... i managed to do it!

                    I wasn't much help, so the credit is yours - well done :)

                    I are Troll :suss:

                    S 1 Reply Last reply
                    0
                    • L Lost User

                      shoubi wrote:

                      thank you for your help... i managed to do it!

                      I wasn't much help, so the credit is yours - well done :)

                      I are Troll :suss:

                      S Offline
                      S Offline
                      shoubi
                      wrote on last edited by
                      #14

                      hi troll i need your help again. how do i insert the dataset into the database. here is my code: string SelectSchema = "SELECT * FROM [Package Data Range]"; DataSet ds = new DataSet(); OleDbDataAdapter adapterPkInfo = new OleDbDataAdapter(SelectSchema, ImportCon); adapterPkInfo.FillSchema(ds, SchemaType.Source, "PackageDataRangeSchema"); DataSet ds2 = new DataSet(); string selectPkInfo = "SELECT * FROM [Package Data Range]"; OleDbDataAdapter adapter = new OleDbDataAdapter(selectPkInfo, connection); adapter.Fill(ds2, "Package Data Range"); ds.Tables[0].Merge(ds2.Tables[0],true,MissingSchemaAction.Ignore); i would like to insert the dataset ds into the database. thank you zheng

                      1 Reply Last reply
                      0
                      • L Lost User

                        Hi, First, you'd need to explain what kind of .mdb-file you want. The file-extension is used by Sql Server and Access, two different types of databases. I'd be assuming Access. First part would be getting a new db on the target-system. The easiest way to do this with Access is by adding an empty db-file as an embedded resource. Second part would be writing the data to the new database. That would be done using OleDb[^].

                        I are Troll :suss:

                        S Offline
                        S Offline
                        shoubi
                        wrote on last edited by
                        #15

                        hi troll I have another question, however it is not related to this. Hope you can give me your professional advice. I have a C# dll, I want to call it from a C++ program. How do I import this dll into the C++. thank you :)

                        L 1 Reply Last reply
                        0
                        • S shoubi

                          hi troll I have another question, however it is not related to this. Hope you can give me your professional advice. I have a C# dll, I want to call it from a C++ program. How do I import this dll into the C++. thank you :)

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #16

                          shoubi wrote:

                          I have another question, however it is not related to this.

                          No problem, but you would have gotten more reactions if you created a new post.

                          shoubi wrote:

                          How do I import this dll into the C++

                          Using a Platform Invoke[^] would be the easy way to call unmanaged code. If you want to wrap an existing unmanaged type, then look here[^]. Enjoy :)

                          I are Troll :suss:

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups