Search code examples
c#datasetsql-updatesqldataadaptersqlcommandbuilder

SqlCommandBuilder Inner Join Update


I have SQL tables as Lessons and Classes. Lessons table has primary key LessonID and Classes table has primary key ClassID. Also ClassID column is foreign key at Lessons table. I import data with SqlDataAdapter to DataSet in C# using query:

select * from Lessons
    inner join Classes on Lessons.LessonID=Classes.ClassID".

I add ddata and edit DataSet via windows form. But it is time to update. I do not know how to update DataSet with SqlDataAdapter because of SqlCommandBuilder does not support "inner join" function. Any ideas?


Solution

  • UPDATE L
    SET <col> = <value>
    FROM Lessons AS L
    INNER JOIN CLasses ON L.LessonID = Classes.ClassID