PC Review


Reply
Thread Tools Rate Thread

datatable and dataset

 
 
=?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
Guest
Posts: n/a
 
      9th Aug 2005
I'd like to create a datatable and add rows to it, but not make it part of a
dataset. so far i've not seen too many examples of this. I believe it can be
done. does anyone know of an example?
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      9th Aug 2005
here is a simple example in VB:

Dim dt As New DataTable
Dim dr As DataRow

dt.Columns.Add("MyNewColumn")

For i As Integer = 1 to 5
dr = dt.NewRow()
dr("MyNewColumn") = "value" & i
dt.Rows.Add(dr)
Next

"WebBuilder451" <(E-Mail Removed)> wrote in message
news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
> I'd like to create a datatable and add rows to it, but not make it part of
> a
> dataset. so far i've not seen too many examples of this. I believe it can
> be
> done. does anyone know of an example?
> thanks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      9th Aug 2005
kes,
Here is an example that I just posted in response to another question:

Dim table As New DataTable("RJN")
table.Columns.Add("InstanceId", GetType(Integer))
table.Columns.Add("LevelId", GetType(Integer))
table.Columns.Add("ParentId", GetType(Integer))

table.Rows.Add(New Object() {100, 1, Nothing})
table.Rows.Add(New Object() {101, 2, 100})
table.Rows.Add(New Object() {102, 3, 101})
table.Rows.Add(New Object() {103, 4, 102})
table.Rows.Add(New Object() {104, 5, 103})
table.Rows.Add(New Object() {105, 5, 104})
table.Rows.Add(New Object() {106, 5, 104})


The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002 &
2003) do not support the ReadXml & WriteXml methods. I understand that .NET
2.0 (VS.NET 2005) will add support for these methods ot DataTable.

Hope this helps
Jay

"WebBuilder451" <(E-Mail Removed)> wrote in message
news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
| I'd like to create a datatable and add rows to it, but not make it part of
a
| dataset. so far i've not seen too many examples of this. I believe it can
be
| done. does anyone know of an example?
| thanks
| kes
| --
| thanks (as always)
| some day i''m gona pay this forum back for all the help i''m getting
| kes


 
Reply With Quote
 
=?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
Guest
Posts: n/a
 
      9th Aug 2005
thanks
related question: i'm trying to bind this to a dropdown list
i'm trying
Me.ddlMemType.DataSource = table.TableName
Me.ddlMemType.DataTextField = ....
this does not work. how would i do this?
thnaks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


"Jay B. Harlow [MVP - Outlook]" wrote:

> kes,
> Here is an example that I just posted in response to another question:
>
> Dim table As New DataTable("RJN")
> table.Columns.Add("InstanceId", GetType(Integer))
> table.Columns.Add("LevelId", GetType(Integer))
> table.Columns.Add("ParentId", GetType(Integer))
>
> table.Rows.Add(New Object() {100, 1, Nothing})
> table.Rows.Add(New Object() {101, 2, 100})
> table.Rows.Add(New Object() {102, 3, 101})
> table.Rows.Add(New Object() {103, 4, 102})
> table.Rows.Add(New Object() {104, 5, 103})
> table.Rows.Add(New Object() {105, 5, 104})
> table.Rows.Add(New Object() {106, 5, 104})
>
>
> The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002 &
> 2003) do not support the ReadXml & WriteXml methods. I understand that .NET
> 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
>
> Hope this helps
> Jay
>
> "WebBuilder451" <(E-Mail Removed)> wrote in message
> news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
> | I'd like to create a datatable and add rows to it, but not make it part of
> a
> | dataset. so far i've not seen too many examples of this. I believe it can
> be
> | done. does anyone know of an example?
> | thanks
> | kes
> | --
> | thanks (as always)
> | some day i''m gona pay this forum back for all the help i''m getting
> | kes
>
>
>

 
Reply With Quote
 
W.G. Ryan MVP
Guest
Posts: n/a
 
      9th Aug 2005
just change it to Me.ddlMemType.DataSource= table
Me.ddlMemType.DataTextField = "FieldName"
"WebBuilder451" <(E-Mail Removed)> wrote in message
news:A80227C5-BDED-4960-9AFE-(E-Mail Removed)...
> thanks
> related question: i'm trying to bind this to a dropdown list
> i'm trying
> Me.ddlMemType.DataSource = table.TableName
> Me.ddlMemType.DataTextField = ....
> this does not work. how would i do this?
> thnaks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes
>
>
> "Jay B. Harlow [MVP - Outlook]" wrote:
>
>> kes,
>> Here is an example that I just posted in response to another question:
>>
>> Dim table As New DataTable("RJN")
>> table.Columns.Add("InstanceId", GetType(Integer))
>> table.Columns.Add("LevelId", GetType(Integer))
>> table.Columns.Add("ParentId", GetType(Integer))
>>
>> table.Rows.Add(New Object() {100, 1, Nothing})
>> table.Rows.Add(New Object() {101, 2, 100})
>> table.Rows.Add(New Object() {102, 3, 101})
>> table.Rows.Add(New Object() {103, 4, 102})
>> table.Rows.Add(New Object() {104, 5, 103})
>> table.Rows.Add(New Object() {105, 5, 104})
>> table.Rows.Add(New Object() {106, 5, 104})
>>
>>
>> The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
>> &
>> 2003) do not support the ReadXml & WriteXml methods. I understand that
>> .NET
>> 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
>>
>> Hope this helps
>> Jay
>>
>> "WebBuilder451" <(E-Mail Removed)> wrote in
>> message
>> news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
>> | I'd like to create a datatable and add rows to it, but not make it part
>> of
>> a
>> | dataset. so far i've not seen too many examples of this. I believe it
>> can
>> be
>> | done. does anyone know of an example?
>> | thanks
>> | kes
>> | --
>> | thanks (as always)
>> | some day i''m gona pay this forum back for all the help i''m getting
>> | kes
>>
>>
>>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      9th Aug 2005
Kes,
As W.G. Ryan states:

Bind only the DataTable itself to the DataSource.

| Me.ddlMemType.DataSource = table
| Me.ddlMemType.DataTextField = ....

By setting the DataSource = table.TableName you were attempting to bind to a
String...

Hope this helps
Jay

"WebBuilder451" <(E-Mail Removed)> wrote in message
news:A80227C5-BDED-4960-9AFE-(E-Mail Removed)...
| thanks
| related question: i'm trying to bind this to a dropdown list
| i'm trying
| Me.ddlMemType.DataSource = table.TableName
| Me.ddlMemType.DataTextField = ....
| this does not work. how would i do this?
| thnaks
| kes
| --
| thanks (as always)
| some day i''m gona pay this forum back for all the help i''m getting
| kes
|
|
| "Jay B. Harlow [MVP - Outlook]" wrote:
|
| > kes,
| > Here is an example that I just posted in response to another question:
| >
| > Dim table As New DataTable("RJN")
| > table.Columns.Add("InstanceId", GetType(Integer))
| > table.Columns.Add("LevelId", GetType(Integer))
| > table.Columns.Add("ParentId", GetType(Integer))
| >
| > table.Rows.Add(New Object() {100, 1, Nothing})
| > table.Rows.Add(New Object() {101, 2, 100})
| > table.Rows.Add(New Object() {102, 3, 101})
| > table.Rows.Add(New Object() {103, 4, 102})
| > table.Rows.Add(New Object() {104, 5, 103})
| > table.Rows.Add(New Object() {105, 5, 104})
| > table.Rows.Add(New Object() {106, 5, 104})
| >
| >
| > The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
&
| > 2003) do not support the ReadXml & WriteXml methods. I understand that
..NET
| > 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
| >
| > Hope this helps
| > Jay
| >
| > "WebBuilder451" <(E-Mail Removed)> wrote in
message
| > news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
| > | I'd like to create a datatable and add rows to it, but not make it
part of
| > a
| > | dataset. so far i've not seen too many examples of this. I believe it
can
| > be
| > | done. does anyone know of an example?
| > | thanks
| > | kes
| > | --
| > | thanks (as always)
| > | some day i''m gona pay this forum back for all the help i''m getting
| > | kes
| >
| >
| >


 
Reply With Quote
 
=?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
Guest
Posts: n/a
 
      9th Aug 2005
thank you both for replying
this works!!
it seems its the simple ones that cause me the most greif!!!
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


"W.G. Ryan MVP" wrote:

> just change it to Me.ddlMemType.DataSource= table
> Me.ddlMemType.DataTextField = "FieldName"
> "WebBuilder451" <(E-Mail Removed)> wrote in message
> news:A80227C5-BDED-4960-9AFE-(E-Mail Removed)...
> > thanks
> > related question: i'm trying to bind this to a dropdown list
> > i'm trying
> > Me.ddlMemType.DataSource = table.TableName
> > Me.ddlMemType.DataTextField = ....
> > this does not work. how would i do this?
> > thnaks
> > kes
> > --
> > thanks (as always)
> > some day i''m gona pay this forum back for all the help i''m getting
> > kes
> >
> >
> > "Jay B. Harlow [MVP - Outlook]" wrote:
> >
> >> kes,
> >> Here is an example that I just posted in response to another question:
> >>
> >> Dim table As New DataTable("RJN")
> >> table.Columns.Add("InstanceId", GetType(Integer))
> >> table.Columns.Add("LevelId", GetType(Integer))
> >> table.Columns.Add("ParentId", GetType(Integer))
> >>
> >> table.Rows.Add(New Object() {100, 1, Nothing})
> >> table.Rows.Add(New Object() {101, 2, 100})
> >> table.Rows.Add(New Object() {102, 3, 101})
> >> table.Rows.Add(New Object() {103, 4, 102})
> >> table.Rows.Add(New Object() {104, 5, 103})
> >> table.Rows.Add(New Object() {105, 5, 104})
> >> table.Rows.Add(New Object() {106, 5, 104})
> >>
> >>
> >> The "problem" currently is that DataTable in .NET 1.0 & 1.1 (VS.NET 2002
> >> &
> >> 2003) do not support the ReadXml & WriteXml methods. I understand that
> >> .NET
> >> 2.0 (VS.NET 2005) will add support for these methods ot DataTable.
> >>
> >> Hope this helps
> >> Jay
> >>
> >> "WebBuilder451" <(E-Mail Removed)> wrote in
> >> message
> >> news:1FE183E8-910B-45F6-A487-(E-Mail Removed)...
> >> | I'd like to create a datatable and add rows to it, but not make it part
> >> of
> >> a
> >> | dataset. so far i've not seen too many examples of this. I believe it
> >> can
> >> be
> >> | done. does anyone know of an example?
> >> | thanks
> >> | kes
> >> | --
> >> | thanks (as always)
> >> | some day i''m gona pay this forum back for all the help i''m getting
> >> | kes
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fix A DataTable named 'Tag2' already belongs to this DataSet.(XML/Datatable) frodenekkoy@hotmail.com Microsoft Dot NET 0 8th Jul 2008 08:14 AM
Copying records from datatable to datatable in dataset tshad Microsoft C# .NET 1 24th Jun 2008 01:39 AM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft ADO .NET 7 9th Dec 2003 02:50 PM
copying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft ADO .NET 2 31st Oct 2003 01:05 PM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft C# .NET 1 31st Oct 2003 02:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:16 PM.