|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Is it possible to use Field Names instead of Item(0) with Data Row using VB.Net 2005 ?Hi,
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 Yes, like this:
Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) dr.Item("ProductID") = 123 dr.Item("ProductName") = "ABC" /claes Show quoteHide quote "Luqman" <pearls***@cyber.net.pk> wrote in message news:euZTpiwUGHA.5552@TK2MSFTNGP14.phx.gbl... > Hi, > > 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 > > Hi,
following line giving error. Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) System.InvalidCastException was unhandled Message="Unable to cast object of type 'System.Data.DataRowView' to type 'System.Data.DataRow'." Any idea please ? Best Regards, Luqman Show quoteHide quote "Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message news:eDWhFqzUGHA.196@TK2MSFTNGP10.phx.gbl... > Yes, like this: > Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) > dr.Item("ProductID") = 123 > dr.Item("ProductName") = "ABC" > > /claes > > "Luqman" <pearls***@cyber.net.pk> wrote in message > news:euZTpiwUGHA.5552@TK2MSFTNGP14.phx.gbl... >> Hi, >> >> 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 >> >> > > Luqman,
BindingSource.Current returns a DataRowView instead of a DataRow, change your cast to be: Dim dr As DataRowView = CType(Me.ProductsBindingSource.Current, DataRowView) DataRowView & DataRow as analogous to DataView & DataTable. If you want the actual DataRow, you can use the DataRowView.Row property: Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRowView).Row -- Hope this helps Jay [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Luqman" <pearls***@cyber.net.pk> wrote in message following line giving error.news:ukprRM0UGHA.5248@TK2MSFTNGP10.phx.gbl... Hi, Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) System.InvalidCastException was unhandled Message="Unable to cast object of type 'System.Data.DataRowView' to type 'System.Data.DataRow'." Any idea please ? Best Regards, Luqman Show quoteHide quote "Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message news:eDWhFqzUGHA.196@TK2MSFTNGP10.phx.gbl... > Yes, like this: > Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) > dr.Item("ProductID") = 123 > dr.Item("ProductName") = "ABC" > > /claes > > "Luqman" <pearls***@cyber.net.pk> wrote in message > news:euZTpiwUGHA.5552@TK2MSFTNGP14.phx.gbl... >> Hi, >> >> 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 >> >> > > Thanks Jay.
Best Regards, Luqman Show quoteHide quote "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_***@tsbradley.net> wrote in message news:uCVM06$UGHA.4772@TK2MSFTNGP14.phx.gbl... > Luqman, > BindingSource.Current returns a DataRowView instead of a DataRow, change > your cast to be: > > Dim dr As DataRowView = CType(Me.ProductsBindingSource.Current, > DataRowView) > > DataRowView & DataRow as analogous to DataView & DataTable. > > If you want the actual DataRow, you can use the DataRowView.Row property: > > Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, > DataRowView).Row > > -- > Hope this helps > Jay [MVP - Outlook] > .NET Application Architect, Enthusiast, & Evangelist > T.S. Bradley - http://www.tsbradley.net > > > "Luqman" <pearls***@cyber.net.pk> wrote in message > news:ukprRM0UGHA.5248@TK2MSFTNGP10.phx.gbl... > Hi, > > following line giving error. > > Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) > > System.InvalidCastException was unhandled > Message="Unable to cast object of type 'System.Data.DataRowView' to type > 'System.Data.DataRow'." > > > Any idea please ? > > > > Best Regards, > > Luqman > > > > > > "Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message > news:eDWhFqzUGHA.196@TK2MSFTNGP10.phx.gbl... > > Yes, like this: > > Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow) > > dr.Item("ProductID") = 123 > > dr.Item("ProductName") = "ABC" > > > > /claes > > > > "Luqman" <pearls***@cyber.net.pk> wrote in message > > news:euZTpiwUGHA.5552@TK2MSFTNGP14.phx.gbl... > >> Hi, > >> > >> 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 > >> > >> > > > > > >
Datagrid with VB 2005
Datagrid problem Doing some extra task while saving databind Controls in VB.Net 2005 ? Late Binding Question large arrays and system.outofmemoryexception DataBinding and Combo Boxes Problems with TCP Listener Oledb VS Sql. Oledb works with Sql Server; Sql doesn't...why Web Panel? select all text when textbox1 is clicked |
|||||||||||||||||||||||