Re: Problem deleting records from datagrid
- From: "Brian Schwartz" <brian@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 17:53:13 -0500
"Ian Davies" <iandan.dav@xxxxxxxxxx> wrote in message
news:%oDQe.1408$B4.70@xxxxxxxxxxxxxxxxxxxxxxx
<snip>
> It is strange that datagrids dont allow records to be deleted if there are
> more than one table. I would have thought that anyone using relational
> datatabases properly would have needed to use more than one table to
display
> the required data in a datagrid.
>
> Im coming to the conclusion that VB and its use as a means of data
> manipulation was not planned as a feature of the programming environment
but
> was just a badly designed after thought.
<snip>
You will sometimes find the same problem in Access if you have a query that
includes multiple tables. It's the natural result of having multiple tables
mashed together in one dataset. VB is good with data manipulation if you are
using ADO (or DAO in the older days), and a good grid. VB has never come
with a good grid though, and I think that's more because Microsoft wants to
encourage the third-party control market than because of neglectful bad
design.
Your design is right on, keeping the descriptions separate. As for whether a
refresh is enough, just try it. If it doesn't work, look for a requery
method. If it doesn't have one, close and reopen the recordset.
BTW, I never use bound controls. At first they seem to do a lot of nice work
for you, but very soon they become hard to manage and you find yourself
having to write workarounds--like this--to get done what you want done, and
the binding ends up saving no trouble at all.
--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Building better tools for developers - Be part of it!
"Ian Davies" <iandan.dav@xxxxxxxxxx> wrote in message
news:%oDQe.1408$B4.70@xxxxxxxxxxxxxxxxxxxxxxx
> Thanks for the reply. You are probably right about it being due to having
> two tables.
>
> The reason I have two tables is that one contains the descriptions
> eg
> Ind1 Desc
> 1 desc 1
> 2 desc 2
> 3 desc 3
> and the other, with all the records, contains only index numbers joined by
> Ind1
> eg
> Ind2 Ind1
> 1 2
> 2 2
> 3 1
> 4 1
> 5 1
> 6 3
> etc
> which is how relational databases should be
>
> However the records displayed in the datagrid need to have the description
> displayed, the index number is meaningless to the user. Hence the two
> tables.
> It is strange that datagrids dont allow records to be deleted if there are
> more than one table. I would have thought that anyone using relational
> datatabases properly would have needed to use more than one table to
display
> the required data in a datagrid.
>
> Im coming to the conclusion that VB and its use as a means of data
> manipulation was not planned as a feature of the programming environment
but
> was just a badly designed after thought.
>
> I thing your last suggestion of using an DELETE statement is the way
around
> the problem.
> I would then need to refresh the data grid to display the changed data
>
> to do this would
> datagrid.refresh do
>
> or would I have to close and then reopen the recordset first?
>
> Ian
>
>
>
>
> "Brian Schwartz" <brian@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:Ov9nusIrFHA.2624@xxxxxxxxxxxxxxxxxxxxxxx
> > Two tables is the problem I bet. You can try including a key for the
other
> > table as well. When you delete, a record from both tables will be
deleted.
> >
> > If that doesn't work, include only one table in the grid, or arrange
some
> > alternate way of deleting from your grid, like a button that looks at
what
> > is selected in the grid, and then executes the appropriate delete
> statement
> > on the database.
> >
> > Hope that helps,
> >
> > --
> > Brian Schwartz
> > FishNet Components
> > http://www.fishnetcomponents.com
> > Building better tools for developers - Be part of it!
> >
> >
> > "Ian Davies" <iandan.dav@xxxxxxxxxx> wrote in message
> > news:rw7Qe.1180$h4.120@xxxxxxxxxxxxxxxxxxxxxxx
> > > Yes, there are two tables in this query and one does have a primary
key,
> > > which is included in the query
> > >
> > >
> > > "Brian Schwartz" <brian@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > news:OLD8qX1qFHA.908@xxxxxxxxxxxxxxxxxxxxxxx
> > > > Does the query the datagrid uses to populate include a primary key
> field
> > > > from the table?
> > > >
> > > > --
> > > > Brian Schwartz
> > > > FishNet Components
> > > > http://www.fishnetcomponents.com
> > > > Building better tools for developers - Be part of it!
> > > >
> > > >
> > > > "Ian Davies" <iandan.dav@xxxxxxxxxx> wrote in message
> > > > news:60qOe.632$kx2.203@xxxxxxxxxxxxxxxxxxxxxxx
> > > > > Hello
> > > > > I have a datagrid linked to a query in Access. I can use this
query
> to
> > > > > delete records from within Access but when I try to do the same
from
> > the
> > > > > datagrid I get the message 'Insufficient key column information
for
> > > > updating
> > > > > or refreshing'. However it lets me edit the records. I have
> > > 'AllowDelete'
> > > > > ticked in the datagrid's properties but this makes no difference
> > > > >
> > > > > Can anyone offer an explanation
> > > > >
> > > > > Thanks
> > > > > Ian
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
.
- References:
- Problem deleting records from datagrid
- From: Ian Davies
- Re: Problem deleting records from datagrid
- From: Brian Schwartz
- Re: Problem deleting records from datagrid
- From: Ian Davies
- Re: Problem deleting records from datagrid
- From: Brian Schwartz
- Re: Problem deleting records from datagrid
- From: Ian Davies
- Problem deleting records from datagrid
- Prev by Date: Re: Save PictureBox contents to a bitmap
- Next by Date: Re: Multiple file select
- Previous by thread: Re: Problem deleting records from datagrid
- Next by thread: how to draw image on mouse down / mouse move
- Index(es):
Loading