If I create a data tabe in C# like so:
datatable t = new DataTable;
DataColum C1 = new DataColum;//ID column
//the same with column C2
Then I fill up the table with some data.
Then the goal is to either insert this data or update data in an SQLtable in SQL. If the data is inserted, the ID column in t would be empty, if updated, it would not be. So in the insertion case, the sql query needs to make sure that unique IDs are assigned during insertion, in the update case, it just has to look for the right IDs.
How to go about this?
Asking because I am only familiar with updating and inserting single lines into a table. One could loop in C# over the datatable t of course and insert or update line by line, but this would probably be slow. Is there a way to write an SQL query like this somehow:
Insert Into SQLTable Values (@t)
And Update like this:
Update SQLTable SET ... Where C1 = @t.C1
Or something like that.
I know that SQL server can create automatic update and insert queries and that you can then type things in C# like
But, this has proven to be super slow on our server, for unknown reasons. I have asked on this forum and got some answers from experts, but was not able to srot out the problem.
How can we write
View Complete Post