Home All Groups Group Topic Archive Search About

Doing some extra task while saving databind Controls in VB.Net 2005 ?

Author
28 Mar 2006 8:05 PM
Luqman
I have created a form using Data Sources in VB.Net 2005, and Binding
Navigator, even I did not write a single line of code and data is
displaying, saving, deleting perfectly with the click of buttons on Binding
Navigator.

Now, what I want, that if the user clicks on the Save Button of Binding
Navigator, one field of that table should be saved with Current Date and
Time.

Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer (typed
dataset).

How can I do so? Any example will be highly appreciated.

Best Regards,

Luqman

Author
28 Mar 2006 11:28 PM
Ken Tucker [MVP]
Hi,

        You can get the current datarow this way

Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ProductsBindingNavigatorSaveItem.Click

Me.Validate()

Me.ProductsBindingSource.EndEdit()

Dim dr As DataRow =
Me.Inventory_Control1DataSet.Products.Item(Me.ProductsBindingSource.CurrencyManager.Position)

MessageBox.Show(dr.Item(0).ToString)

'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

End Sub



Ken

----------------

Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:%233qZGMqUGHA.5148@TK2MSFTNGP12.phx.gbl...
>I have created a form using Data Sources in VB.Net 2005, and Binding
>Navigator, even I did not write a single line of code and data is
>displaying, saving, deleting perfectly with the click of buttons on Binding
>Navigator.
>
> Now, what I want, that if the user clicks on the Save Button of Binding
> Navigator, one field of that table should be saved with Current Date and
> Time.
>
> Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer (typed
> dataset).
>
> How can I do so? Any example will be highly appreciated.
>
> Best Regards,
>
> Luqman
>
>
>
>
>
Author
29 Mar 2006 5:43 AM
Jim Hughes
You can also use the new (in 2005) Current property

Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ProductsBindingNavigatorSaveItem.Click

if Me.ProductsBindingSource.Current Is Nothing Then Exit Sub

Me.Validate()

Me.ProductsBindingSource.EndEdit()

Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)

MessageBox.Show(dr.Item(0).ToString)

'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

End Sub



Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uHeWp9rUGHA.1688@TK2MSFTNGP11.phx.gbl...
> Hi,
>
>        You can get the current datarow this way
>
> Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> ProductsBindingNavigatorSaveItem.Click
>
> Me.Validate()
>
> Me.ProductsBindingSource.EndEdit()
>
> Dim dr As DataRow =
> Me.Inventory_Control1DataSet.Products.Item(Me.ProductsBindingSource.CurrencyManager.Position)
>
> MessageBox.Show(dr.Item(0).ToString)
>
> 'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
>
> End Sub
>
>
>
> Ken
>
> ----------------
>
> "Luqman" <pearls***@cyber.net.pk> wrote in message
> news:%233qZGMqUGHA.5148@TK2MSFTNGP12.phx.gbl...
>>I have created a form using Data Sources in VB.Net 2005, and Binding
>>Navigator, even I did not write a single line of code and data is
>>displaying, saving, deleting perfectly with the click of buttons on
>>Binding Navigator.
>>
>> Now, what I want, that if the user clicks on the Save Button of Binding
>> Navigator, one field of that table should be saved with Current Date and
>> Time.
>>
>> Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer (typed
>> dataset).
>>
>> How can I do so? Any example will be highly appreciated.
>>
>> Best Regards,
>>
>> Luqman
>>
>>
>>
>>
>>
>
>
Author
29 Mar 2006 7:52 AM
Luqman
Hi,

Ok, I understood, is it possible to use Field Names with Data Row.

for example:

  Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)
dr.ProductID=123
dr.ProductName="ABC"
Me.ProductsBindingSource.EndEdit()
Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

Best Regards,

Luqman





Show quoteHide quote
"Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message
news:OdRjoOvUGHA.1572@tk2msftngp13.phx.gbl...
> You can also use the new (in 2005) Current property
>
>  Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
>  System.Object, ByVal e As System.EventArgs) Handles
>  ProductsBindingNavigatorSaveItem.Click
>
> if Me.ProductsBindingSource.Current Is Nothing Then Exit Sub
>
>  Me.Validate()
>
>  Me.ProductsBindingSource.EndEdit()
>
>  Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)
>
>  MessageBox.Show(dr.Item(0).ToString)
>
>  'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
>
>  End Sub
>
>
>
> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
> news:uHeWp9rUGHA.1688@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> >        You can get the current datarow this way
> >
> > Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
> > System.Object, ByVal e As System.EventArgs) Handles
> > ProductsBindingNavigatorSaveItem.Click
> >
> > Me.Validate()
> >
> > Me.ProductsBindingSource.EndEdit()
> >
> > Dim dr As DataRow =
> >
Me.Inventory_Control1DataSet.Products.Item(Me.ProductsBindingSource.Currency
Manager.Position)
Show quoteHide quote
> >
> > MessageBox.Show(dr.Item(0).ToString)
> >
> > 'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
> >
> > End Sub
> >
> >
> >
> > Ken
> >
> > ----------------
> >
> > "Luqman" <pearls***@cyber.net.pk> wrote in message
> > news:%233qZGMqUGHA.5148@TK2MSFTNGP12.phx.gbl...
> >>I have created a form using Data Sources in VB.Net 2005, and Binding
> >>Navigator, even I did not write a single line of code and data is
> >>displaying, saving, deleting perfectly with the click of buttons on
> >>Binding Navigator.
> >>
> >> Now, what I want, that if the user clicks on the Save Button of Binding
> >> Navigator, one field of that table should be saved with Current Date
and
> >> Time.
> >>
> >> Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer
(typed
> >> dataset).
> >>
> >> How can I do so? Any example will be highly appreciated.
> >>
> >> Best Regards,
> >>
> >> Luqman
> >>
> >>
> >>
> >>
> >>
> >
> >
>
>
Author
30 Mar 2006 1:18 PM
Jim Hughes
Yes, if you use a "Typed DataSet" instead of a generic DataRow.

Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:OFxYYVwUGHA.4248@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Ok, I understood, is it possible to use Field Names with Data Row.
>
> for example:
>
>  Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)
> dr.ProductID=123
> dr.ProductName="ABC"
> Me.ProductsBindingSource.EndEdit()
> Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
>
> Best Regards,
>
> Luqman
>
>
>
>
>
> "Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message
> news:OdRjoOvUGHA.1572@tk2msftngp13.phx.gbl...
>> You can also use the new (in 2005) Current property
>>
>>  Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
>>  System.Object, ByVal e As System.EventArgs) Handles
>>  ProductsBindingNavigatorSaveItem.Click
>>
>> if Me.ProductsBindingSource.Current Is Nothing Then Exit Sub
>>
>>  Me.Validate()
>>
>>  Me.ProductsBindingSource.EndEdit()
>>
>>  Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)
>>
>>  MessageBox.Show(dr.Item(0).ToString)
>>
>>  'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
>>
>>  End Sub
>>
>>
>>
>> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
>> news:uHeWp9rUGHA.1688@TK2MSFTNGP11.phx.gbl...
>> > Hi,
>> >
>> >        You can get the current datarow this way
>> >
>> > Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
>> > System.Object, ByVal e As System.EventArgs) Handles
>> > ProductsBindingNavigatorSaveItem.Click
>> >
>> > Me.Validate()
>> >
>> > Me.ProductsBindingSource.EndEdit()
>> >
>> > Dim dr As DataRow =
>> >
> Me.Inventory_Control1DataSet.Products.Item(Me.ProductsBindingSource.Currency
> Manager.Position)
>> >
>> > MessageBox.Show(dr.Item(0).ToString)
>> >
>> > 'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)
>> >
>> > End Sub
>> >
>> >
>> >
>> > Ken
>> >
>> > ----------------
>> >
>> > "Luqman" <pearls***@cyber.net.pk> wrote in message
>> > news:%233qZGMqUGHA.5148@TK2MSFTNGP12.phx.gbl...
>> >>I have created a form using Data Sources in VB.Net 2005, and Binding
>> >>Navigator, even I did not write a single line of code and data is
>> >>displaying, saving, deleting perfectly with the click of buttons on
>> >>Binding Navigator.
>> >>
>> >> Now, what I want, that if the user clicks on the Save Button of
>> >> Binding
>> >> Navigator, one field of that table should be saved with Current Date
> and
>> >> Time.
>> >>
>> >> Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer
> (typed
>> >> dataset).
>> >>
>> >> How can I do so? Any example will be highly appreciated.
>> >>
>> >> Best Regards,
>> >>
>> >> Luqman
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>