[Last Call] Learn how to a build a cloud-first strategyRegister Now


How do I update and delete from a datagridview that is bound to a view table from a database?

Posted on 2006-05-28
Medium Priority
Last Modified: 2010-04-23
I have VS 2005. I have created a  view in my database combining data from 2 different tables. I can update & delete from Ent. Mgr. When I create a datagrid view or a "details"  object from the datasource in my ADO.Net app., I get the data from the combined tables entered into the form, but the "save" button is not enabled. I enable the the button but I still cannot update the data entered or deleted in the form. How do I manipulate the data in my dataview thru my form?

Question by:grouchyfd
  • 3
  • 2

Author Comment

ID: 16780714
Or another way of putting it, I want to add an unbound column to a datagrid. That datagrid is already bound to a data table. Column1 in the datagridview is EmployeeID and shows the ID number. I would like Column1 to show the Name associated with the EmployeeID from the related Employee table, instead of the ID number.
LVL 96

Expert Comment

by:Bob Learned
ID: 16785122
1) If you are using Inner Joins, or any other complex queries like that, you will not be able to update.  

2) Are you using Table adapters?


Author Comment

ID: 16786317
I tried to create a view using joins and found that the table adapter wouldn't allow me to update. When I tried to code it, the intelisence would not bring up the update command. When I go to Enterprise manager and create a view there, I can update it. I guess I'll try to see if I can do it through a SQL command.
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 16786550
The table adapter needs enough key information to update the tables.  Maybe it is because you haven't included enough fields from the secondary table to do an update.


Author Comment

ID: 16791467
I won't be able to get to my machine until tomorrow. But I'll have to see if I included or not the PK field. I didn't really think about not having enough of the fields, but it does sound logical.

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question