|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add new row to typed datasetHow do I add a new DataRow to a typed DataSet?
I would expect the following code to work: Dim drCustomer As NorthwindDataSet.CustomerRow drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow drCustomer.CompanyName = "xxx" But the NewCustomersRow method is not valid. It doesn't even come up in IntelliSense. The database is in SqlServerCe (for PDAs), but that shouldn't make a difference. Thanks for any assistance. Is this a Compact Framework applicatoin? If so, 1.x or 2.0?
Show quote "SH" <sham***@prupipe.com> wrote in message news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... > How do I add a new DataRow to a typed DataSet? > > I would expect the following code to work: > > Dim drCustomer As NorthwindDataSet.CustomerRow > drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow > drCustomer.CompanyName = "xxx" > > But the NewCustomersRow method is not valid. It doesn't even come up in > IntelliSense. > > The database is in SqlServerCe (for PDAs), but that shouldn't make a > difference. > > Thanks for any assistance. Compact Framework 2.0.
W.G. Ryan - MVP wrote: Show quote > Is this a Compact Framework applicatoin? If so, 1.x or 2.0? > "SH" <sham***@prupipe.com> wrote in message > news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... > >>How do I add a new DataRow to a typed DataSet? >> >>I would expect the following code to work: >> >>Dim drCustomer As NorthwindDataSet.CustomerRow >>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>drCustomer.CompanyName = "xxx" >> >>But the NewCustomersRow method is not valid. It doesn't even come up in >>IntelliSense. >> >>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>difference. >> >>Thanks for any assistance. > > > DataSet1 ds = new DataSet1();
DataSet1.DataTable1Row = ds.DataTable1.NewDataTable1Row(); --This syntax is working with mine. You may need to save the dataset again, but it should be working. Show quote "SH" <sham***@prupipe.com> wrote in message news:tRQzf.6728$WY5.4054@newsread2.news.pas.earthlink.net... > Compact Framework 2.0. > > W.G. Ryan - MVP wrote: >> Is this a Compact Framework applicatoin? If so, 1.x or 2.0? >> "SH" <sham***@prupipe.com> wrote in message >> news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... >> >>>How do I add a new DataRow to a typed DataSet? >>> >>>I would expect the following code to work: >>> >>>Dim drCustomer As NorthwindDataSet.CustomerRow >>>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>>drCustomer.CompanyName = "xxx" >>> >>>But the NewCustomersRow method is not valid. It doesn't even come up in >>>IntelliSense. >>> >>>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>>difference. >>> >>>Thanks for any assistance. >> >> The syntax doesn't work for me.
I still don't get NewDataTable1Row as a method. All I get are Equals, GetDataTableSchema, GetTypedDataSchema and ReferenceEquals as valid methods for the table. Is there something I'm missing in the table definition? W.G. Ryan - MVP wrote: Show quote > DataSet1 ds = new DataSet1(); > > DataSet1.DataTable1Row = ds.DataTable1.NewDataTable1Row(); > > --This syntax is working with mine. You may need to save the dataset again, > but it should be working. > > "SH" <sham***@prupipe.com> wrote in message > news:tRQzf.6728$WY5.4054@newsread2.news.pas.earthlink.net... > >>Compact Framework 2.0. >> >>W.G. Ryan - MVP wrote: >> >>>Is this a Compact Framework applicatoin? If so, 1.x or 2.0? >>>"SH" <sham***@prupipe.com> wrote in message >>>news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... >>> >>> >>>>How do I add a new DataRow to a typed DataSet? >>>> >>>>I would expect the following code to work: >>>> >>>>Dim drCustomer As NorthwindDataSet.CustomerRow >>>>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>>>drCustomer.CompanyName = "xxx" >>>> >>>>But the NewCustomersRow method is not valid. It doesn't even come up in >>>>IntelliSense. >>>> >>>>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>>>difference. >>>> >>>>Thanks for any assistance. >>> >>> > I'm assuing you already have a acolumn in it right? I just added a dataSet,
added a dataTable, added a column and used it like that. That's the exact syntax and it compiled and ran. You may want to look in the vb or cs file that is the dataset and see if something is missing. Show quote "SH" <sham***@prupipe.com> wrote in message news:2LRzf.3989$Hd4.2679@newsread1.news.pas.earthlink.net... > The syntax doesn't work for me. > > I still don't get NewDataTable1Row as a method. All I get are Equals, > GetDataTableSchema, GetTypedDataSchema and ReferenceEquals as valid > methods for the table. > > Is there something I'm missing in the table definition? > > W.G. Ryan - MVP wrote: >> DataSet1 ds = new DataSet1(); >> >> DataSet1.DataTable1Row = ds.DataTable1.NewDataTable1Row(); >> >> --This syntax is working with mine. You may need to save the dataset >> again, but it should be working. >> >> "SH" <sham***@prupipe.com> wrote in message >> news:tRQzf.6728$WY5.4054@newsread2.news.pas.earthlink.net... >> >>>Compact Framework 2.0. >>> >>>W.G. Ryan - MVP wrote: >>> >>>>Is this a Compact Framework applicatoin? If so, 1.x or 2.0? >>>>"SH" <sham***@prupipe.com> wrote in message >>>>news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... >>>> >>>> >>>>>How do I add a new DataRow to a typed DataSet? >>>>> >>>>>I would expect the following code to work: >>>>> >>>>>Dim drCustomer As NorthwindDataSet.CustomerRow >>>>>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>>>>drCustomer.CompanyName = "xxx" >>>>> >>>>>But the NewCustomersRow method is not valid. It doesn't even come up in >>>>>IntelliSense. >>>>> >>>>>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>>>>difference. >>>>> >>>>>Thanks for any assistance. >>>> >>>> >> Try running the custom tool on the dataset from the context menu. The
generated code may not have been regenerated. Show quote "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message news:exoEyETHGHA.3936@TK2MSFTNGP12.phx.gbl... > I'm assuing you already have a acolumn in it right? I just added a > dataSet, added a dataTable, added a column and used it like that. That's > the exact syntax and it compiled and ran. You may want to look in the vb > or cs file that is the dataset and see if something is missing. > "SH" <sham***@prupipe.com> wrote in message > news:2LRzf.3989$Hd4.2679@newsread1.news.pas.earthlink.net... >> The syntax doesn't work for me. >> >> I still don't get NewDataTable1Row as a method. All I get are Equals, >> GetDataTableSchema, GetTypedDataSchema and ReferenceEquals as valid >> methods for the table. >> >> Is there something I'm missing in the table definition? >> >> W.G. Ryan - MVP wrote: >>> DataSet1 ds = new DataSet1(); >>> >>> DataSet1.DataTable1Row = ds.DataTable1.NewDataTable1Row(); >>> >>> --This syntax is working with mine. You may need to save the dataset >>> again, but it should be working. >>> >>> "SH" <sham***@prupipe.com> wrote in message >>> news:tRQzf.6728$WY5.4054@newsread2.news.pas.earthlink.net... >>> >>>>Compact Framework 2.0. >>>> >>>>W.G. Ryan - MVP wrote: >>>> >>>>>Is this a Compact Framework applicatoin? If so, 1.x or 2.0? >>>>>"SH" <sham***@prupipe.com> wrote in message >>>>>news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... >>>>> >>>>> >>>>>>How do I add a new DataRow to a typed DataSet? >>>>>> >>>>>>I would expect the following code to work: >>>>>> >>>>>>Dim drCustomer As NorthwindDataSet.CustomerRow >>>>>>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>>>>>drCustomer.CompanyName = "xxx" >>>>>> >>>>>>But the NewCustomersRow method is not valid. It doesn't even come up >>>>>>in IntelliSense. >>>>>> >>>>>>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>>>>>difference. >>>>>> >>>>>>Thanks for any assistance. >>>>> >>>>> >>> > > OK. Thanks guys. Your assistance got me poking around in the right
places and I found what my problem was - my TableAdapter was not set up correctly. Thanks. Without your help I would have spent much longer on this. W.G. Ryan - MVP wrote: Show quote > I'm assuing you already have a acolumn in it right? I just added a dataSet, > added a dataTable, added a column and used it like that. That's the exact > syntax and it compiled and ran. You may want to look in the vb or cs file > that is the dataset and see if something is missing. > "SH" <sham***@prupipe.com> wrote in message > news:2LRzf.3989$Hd4.2679@newsread1.news.pas.earthlink.net... > >>The syntax doesn't work for me. >> >>I still don't get NewDataTable1Row as a method. All I get are Equals, >>GetDataTableSchema, GetTypedDataSchema and ReferenceEquals as valid >>methods for the table. >> >>Is there something I'm missing in the table definition? >> >>W.G. Ryan - MVP wrote: >> >>>DataSet1 ds = new DataSet1(); >>> >>>DataSet1.DataTable1Row = ds.DataTable1.NewDataTable1Row(); >>> >>>--This syntax is working with mine. You may need to save the dataset >>>again, but it should be working. >>> >>>"SH" <sham***@prupipe.com> wrote in message >>>news:tRQzf.6728$WY5.4054@newsread2.news.pas.earthlink.net... >>> >>> >>>>Compact Framework 2.0. >>>> >>>>W.G. Ryan - MVP wrote: >>>> >>>> >>>>>Is this a Compact Framework applicatoin? If so, 1.x or 2.0? >>>>>"SH" <sham***@prupipe.com> wrote in message >>>>>news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... >>>>> >>>>> >>>>> >>>>>>How do I add a new DataRow to a typed DataSet? >>>>>> >>>>>>I would expect the following code to work: >>>>>> >>>>>>Dim drCustomer As NorthwindDataSet.CustomerRow >>>>>>drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow >>>>>>drCustomer.CompanyName = "xxx" >>>>>> >>>>>>But the NewCustomersRow method is not valid. It doesn't even come up in >>>>>>IntelliSense. >>>>>> >>>>>>The database is in SqlServerCe (for PDAs), but that shouldn't make a >>>>>>difference. >>>>>> >>>>>>Thanks for any assistance. >>>>> >>>>> > > Hi,
"SH" <sham***@prupipe.com> wrote in message NorthwindDataSet.CustomersDataTable is an inner class, you need an instance. news:SpPzf.620$Dk.467@newsread3.news.pas.earthlink.net... > How do I add a new DataRow to a typed DataSet? > > I would expect the following code to work: > > Dim drCustomer As NorthwindDataSet.CustomerRow > drCustomer = NorthwindDataSet.CustomersDataTable.NewCustomersRow > drCustomer.CompanyName = "xxx" If there is a NorthwindDataSet on the form with the same name, then NorthwindDataSet can be both a class and instance, depending on how you further qualify it (VB.NET). In this case the instance you need is NorthwindDataSet.Customers (without the DataTable part). Dim drCustomer As NorthwindDataSet.CustomerRow drCustomer = NorthwindDataSet.Customers.NewCustomersRow() drCustomer.CompanyName = "xxx" If there is no NorthwindDataSet on the Form, then you need to what W.G. Ryan suggested, create an instance first: Dim dsNorthwind As New NorthwindDataSet() Dim drCustomer As NorthwindDataSet.CustomerRow drCustomer = dsNorthwind.Customers.NewCustomersRow() drCustomer.CompanyName = "xxx" HTH, Greetings Show quote > > But the NewCustomersRow method is not valid. It doesn't even come up in > IntelliSense. > > The database is in SqlServerCe (for PDAs), but that shouldn't make a > difference. > > Thanks for any assistance. |
|||||||||||||||||||||||