RE: DataGrid

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Rakesh Rajan (RakeshRajan_at_discussions.microsoft.com)
Date: 10/15/04


Date: Fri, 15 Oct 2004 12:15:07 -0700

Hi,

OK.

Make sure that both the adapter, and dataset is declared within the class
scope and not in a method. For this, just make sure that their declarations
are somewhere within the class definition but not within any method.

Now add an event handler to the Add button (double click on the Add button
in design time to do this). Within the handler, call the dataadapter's Update
method, passing the dataset name.
For eg:
myDataAdapter.Update(myDataSet);
, which assumes that 'myDataAdapter' is my dataadapter and 'myDataSet' is
the dataset.

Let me know if you need more help.

Regards,
Rakesh Rajan
"NewBie" wrote:

> Yes I did using the fill method.
>
> "Rakesh Rajan" wrote:
>
> > Hi NewBie,
> >
> > One question - have you loaded data from the DB into the datagrid?
> >
> > Regards,
> > Rakesh Rajan
> >
> > "NewBie" wrote:
> >
> > > You are right in you assumption. I do have a DB that have existing data. I
> > > have no clue how to do ''call the dataadapter's Update method, passing the
> > > dataset you use."
> > > The book I am using does not give me any info on how call the adapter.
> > >
> > >
> > >
> > > "Rakesh Rajan" wrote:
> > >
> > > > Hi,
> > > >
> > > > I assume that you have a datagrid, and a dataset populated by a dataadapter
> > > > with data from the DB, and that any existing data in the DB is shown in it.
> > > >
> > > > For updating the DB, just edit any existing row.
> > > > In order to insert, insert a new value in the row with a '*'.
> > > >
> > > > Within the handlers for Update and Add button click events, call the
> > > > dataadapter's Update method, passing the dataset you use.
> > > >
> > > > Let me know if you still have problems.
> > > >
> > > > HTH,
> > > > Rakesh Rajan
> > > >
> > > > "NewBie" wrote:
> > > >
> > > > > I have my datagrid setup, I can see my table in my form and I have added a
> > > > > connection and cfg the adapter. Now I need to add data to it from a btnAdd.
> > > > >
> > > > > "Rakesh Rajan" wrote:
> > > > >
> > > > > > Hi Newbe,
> > > > > >
> > > > > > Your issue is not very clear. Basically, to perform updates, you need a
> > > > > > command object, or use an adapter and a dataset. You set the connection, and
> > > > > > command properties to those objects and execute them. But I don't know which
> > > > > > portion you haven't got right.
> > > > > >
> > > > > > Check out this walk thru from MSDN:
> > > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughdisplayingdatafromsingletableinwindowsform.asp
> > > > > >
> > > > > > Let me know if you need more help.
> > > > > >
> > > > > > HTH,
> > > > > > Rakesh Rajan
> > > > > >
> > > > > > "Newbe" wrote:
> > > > > >
> > > > > > > I need help in a bad way. I have a form with a datagrid in it coming for a
> > > > > > > Access DB. I have 3 columns, StudentName, Address, Phone. I am using
> > > > > > > Me.bindingcontext(School11, "Student") to bind buttons like first, next ect...
> > > > > > >
> > > > > > > I have a button Add/Edit and Update to Disk and Insert
> > > > > > > I have no idea how to code this so I can add a record to the above table.
> > > > > > > Can someone please help me!


Quantcast