Update joined TableAdapter


M

Magnus

Hi!
(Read this with font courier new or equal)
I have a table adapter which fills a datatable with data from two sql tables: Properties, and PropCompanyInfo:

tbl1.PropertyID pk identity(0,1)
tbl1.PropertyName
tbl2.ID pk identity(0,1)
tbl2._PropertyID
tbl2.CompID
tbl2.Comment

Selected with the query SELECT tbl1.PropertyID, tbl1.PropertyName, tbl2.ID, tbl2._PropertyID, tbl2.CompID, tbl2.Comment from Properties
left outer join PropCompanyInfo on tbl1.PropertyID = tbl2.PropertyID and tbl2.CompID = @CID
The result is all rows from Properties, joined with PropCompanyInfo where found.

I have a datagrid where the user should add or edit comments (the rows amount is static).
Could look like:
PropertyID PropertyName ID _PropertyID CompID Comment
7 Birdland
12 Fireland

As you can see in this example there are no rows with comments for this company.
Now I want to update tbl2 with all rows that have a comment added. I get the message that ID don't allow null. I also have to set the _PropertyID to the same as PropertyID, and the CompID has to be set somehow.

Since I have a dataset with a datatable, I think this could be made without events for the grid and other code?

I'm not a full time developer, so I think there are some fundamental things I don't get here? HELP!

Regards Magnus
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top