954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Insert data to 2 tables at the same time

Hello,

I have 2 tables: news and users

news
- N_id (primary)
- title
- article
- time
- U_id

users
- U_id (primary)
- member

I have managed to create the gridview with edit/add/delete for news only, without incorporating the users who wrote that news article.

My question here is how can I add a column for the member in the main gridview so that whenever I add a new row, I can select a member (id) to go along with the article.

drugoholic
Light Poster
28 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

Hello, drugoholic.
The first fast idea that came to me is:
1. Create a DataSource in your project and bind a grid to it (I'm not considering here custom cell renders, so we can focus on the approach).
2. Modify the DataSource (Including it's TableAdapter and DataSet) to return the given query. You can easily write your own sql-commands in SelectCommand (or other similar) property.
3. Voala! You have customized data displayed in your grid.

This is just a base idea. But, as for me, it's better to write the custom dataSource to achieve this (I guess, it would be more clean solution :)).

Antenka
Posting Whiz
362 posts since Nov 2008
Reputation Points: 293
Solved Threads: 82
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: