Home All Groups Group Topic Archive Search About

datagridview filled with a view

Author
7 Jul 2006 1:59 PM
Danny M
I want to fill a datagridview with a tabel, only problem is one of the
fields of this tabel is an ID to another tabel with the name.. I want
to also show the name in the grid (they cant edit this field)

To to this I can use a sql server view, right?

But when i use a view i cant use the standard update command?
Or is this possible by just deleting the added name column?

Author
7 Jul 2006 3:01 PM
Brian Tkatch
Danny M wrote:
> I want to fill a datagridview with a tabel, only problem is one of the
> fields of this tabel is an ID to another tabel with the name.. I want
> to also show the name in the grid (they cant edit this field)
>
> To to this I can use a sql server view, right?
>
> But when i use a view i cant use the standard update command?
> Or is this possible by just deleting the added name column?

> I want to fill a datagridview with a tabel

It is not Fill()ed with a TABLE. It is Fill()ed by the SelectCommand in
the DataAdaptor, which can be (via CommandType) a StoredProcedure,
TableDirect, or Text.

> To to this I can use a sql server view, right?

Yes. Just set the SelectCommand to pull data from the view.

> But when i use a view i cant use the standard update command?

Whether the VIEW is UPDATEable is a database question, not a .NET one.
Ultimately, assuming you are using a DataAdaptor, the UPDATE is based
on the UpdateCommand, which is any Command you set it to be, and has
the ability to have absolutely nothing to do with the SelectCommand.

> Or is this possible by just deleting the added name column?

Huh?

--

Just write a query that joins the lookup TABLE to the main TABLE, and
put that in your SelectCommand. The UpdateCommand should not require a
change.

B.