Home All Groups Group Topic Archive Search About

Working with BindingSource & AddNew

Author
7 Jul 2006 4:29 PM
Dustin Davis
I'm trying to add a new row to my database using the BindingSource. I
assume it is possible...

Below is my code snippet:


Dim drvZone As DataRowView
Try
     drvZone = Me.ZonesBindingSource.AddNew()
     drvZone.Row.Item(1) = ProcessID
     drvZone.Row.Item(2) = Me.txtTop.Text
     drvZone.Row.Item(3) = Me.txtLeft.Text
     drvZone.Row.Item(4) = Me.txtBottom.Text
     drvZone.Row.Item(5) = Me.txtRight.Text
     drvZone.Row.Item(6) = Me.txtZoneName.Text
     Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
     MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try



I don't get any errors, but it also doesn't add a record to the
database. Can anyone tell me what I'm doing wrong, or how to go about
adding a record to the database using the BindingSource, or should I go
about it another way?

Thanks,
Dustin

Author
7 Jul 2006 6:05 PM
Dustin Davis
Nevermind. I figured it out.

Dustin Davis wrote:
Show quoteHide quote
> I'm trying to add a new row to my database using the BindingSource. I
> assume it is possible...
>
> Below is my code snippet:
>
>
> Dim drvZone As DataRowView
> Try
>     drvZone = Me.ZonesBindingSource.AddNew()
>     drvZone.Row.Item(1) = ProcessID
>     drvZone.Row.Item(2) = Me.txtTop.Text
>     drvZone.Row.Item(3) = Me.txtLeft.Text
>     drvZone.Row.Item(4) = Me.txtBottom.Text
>     drvZone.Row.Item(5) = Me.txtRight.Text
>     drvZone.Row.Item(6) = Me.txtZoneName.Text
>     Me.ZonesTableAdapter.Update(Me.DsZones)
> Catch ex As Exception
>     MsgBox(ex.Message, MsgBoxStyle.Critical)
> End Try
>
>
>
> I don't get any errors, but it also doesn't add a record to the
> database. Can anyone tell me what I'm doing wrong, or how to go about
> adding a record to the database using the BindingSource, or should I go
> about it another way?
>
> Thanks,
> Dustin
Author
1 Sep 2006 10:27 PM
MartinMCU
How did you solve the problem? I think that I'm running into the same thing.
Thanks,

Matt

Show quoteHide quote
"Dustin Davis" wrote:

> Nevermind. I figured it out.
>
> Dustin Davis wrote:
> > I'm trying to add a new row to my database using the BindingSource. I
> > assume it is possible...
> >
> > Below is my code snippet:
> >
> >
> > Dim drvZone As DataRowView
> > Try
> >     drvZone = Me.ZonesBindingSource.AddNew()
> >     drvZone.Row.Item(1) = ProcessID
> >     drvZone.Row.Item(2) = Me.txtTop.Text
> >     drvZone.Row.Item(3) = Me.txtLeft.Text
> >     drvZone.Row.Item(4) = Me.txtBottom.Text
> >     drvZone.Row.Item(5) = Me.txtRight.Text
> >     drvZone.Row.Item(6) = Me.txtZoneName.Text
> >     Me.ZonesTableAdapter.Update(Me.DsZones)
> > Catch ex As Exception
> >     MsgBox(ex.Message, MsgBoxStyle.Critical)
> > End Try
> >
> >
> >
> > I don't get any errors, but it also doesn't add a record to the
> > database. Can anyone tell me what I'm doing wrong, or how to go about
> > adding a record to the database using the BindingSource, or should I go
> > about it another way?
> >
> > Thanks,
> > Dustin
>