Linq Insert
-
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, -
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, -
Is this a table in your database or a DataTable in code? If it is database table, which database are you using?
am using MSSQL 2008 thanks
-
am using MSSQL 2008 thanks
-
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
-
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
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.
-
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.
ok cheers mate
-
ok cheers mate
Something like this:
var customer=new Customer(12,"Pavel","Yermalovich"); YourDataContext db=new YourDataContext(); db.Customers.InsertOnSubmit(customer); db.SubmitChanges();