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. LINQ
  4. Linq Insert

Linq Insert

Scheduled Pinned Locked Moved LINQ
csharptutoriallinq
8 Posts 3 Posters 1 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 Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    Hi ppl, I want to insert data from one table to another using Linq C#. Can anyone let me know how to do this. something similar to Insert into tbTest (test_id , test_name , test_type) select (mytest_ID , myTest_Name , 1) from myTestTable Please provide an example or syntax in linq Thanks,

    D 1 Reply Last reply
    0
    • S spankyleo123

      Hi ppl, I want to insert data from one table to another using Linq C#. Can anyone let me know how to do this. something similar to Insert into tbTest (test_id , test_name , test_type) select (mytest_ID , myTest_Name , 1) from myTestTable Please provide an example or syntax in linq Thanks,

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Is this a table in your database or a DataTable in code? If it is database table, which database are you using?

      S 1 Reply Last reply
      0
      • D dan sh

        Is this a table in your database or a DataTable in code? If it is database table, which database are you using?

        S Offline
        S Offline
        spankyleo123
        wrote on last edited by
        #3

        am using MSSQL 2008 thanks

        D 1 Reply Last reply
        0
        • S spankyleo123

          am using MSSQL 2008 thanks

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          You need LINQ to SQL here. See this[^] article.

          S 1 Reply Last reply
          0
          • D dan sh

            You need LINQ to SQL here. See this[^] article.

            S Offline
            S Offline
            spankyleo123
            wrote on last edited by
            #5

            yeah am using Linq-to-SQL dataclasses in my project. I just want to run an update on button click which will insert data from one table to another table. I dont know how it is done using LINQ. The example shows insert into just one table. I want to insert values from one table to another. Help appreciated

            D 1 Reply Last reply
            0
            • S spankyleo123

              yeah am using Linq-to-SQL dataclasses in my project. I just want to run an update on button click which will insert data from one table to another table. I dont know how it is done using LINQ. The example shows insert into just one table. I want to insert values from one table to another. Help appreciated

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              You will have to first perform a retrieve and then perform a insert. Just go through the links too in that article it would tell how to retrieve data as well. If all you are doing is transferring data from one table to another, there is no need to getting the data in the application. Place a stored procedure which would do that and just call that from your application. If this is all what your application does, you don't really need it. A SQL job would be fine.

              S 1 Reply Last reply
              0
              • D dan sh

                You will have to first perform a retrieve and then perform a insert. Just go through the links too in that article it would tell how to retrieve data as well. If all you are doing is transferring data from one table to another, there is no need to getting the data in the application. Place a stored procedure which would do that and just call that from your application. If this is all what your application does, you don't really need it. A SQL job would be fine.

                S Offline
                S Offline
                spankyleo123
                wrote on last edited by
                #7

                ok cheers mate

                P 1 Reply Last reply
                0
                • S spankyleo123

                  ok cheers mate

                  P Offline
                  P Offline
                  Pavel Yermalovich
                  wrote on last edited by
                  #8

                  Something like this: var customer=new Customer(12,"Pavel","Yermalovich"); YourDataContext db=new YourDataContext(); db.Customers.InsertOnSubmit(customer); db.SubmitChanges();

                  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