Hi,

I have this code:

--------------------------------------------
Dim myDataSet As DataSet
myDataSet = New DataSet("Funcionarios")
' Create two DataTable objects using a function.
Dim table As New DataTable()
Dim col as DataColumn
Dim data, dia, mes, ano as String
Dim horas as Date
Dim strValor as Date


'Adicionar três colunas
col = New DataColumn ("CdRcs", System.Type.GetType("System.String"))
table.Columns.Add(col)
col = New DataColumn ("Name", System.Type.GetType("System.String"))
table.Columns.Add(col)
col = New DataColumn ("Pwd", System.Type.GetType("System.String"))
table.Columns.Add(col)

myDataSet.Tables.Add(table)
Console.WriteLine(myDataSet.DataSetName, myDataSet.Tables.Count)
--------------------------------------------

Now I want to add some rows to myDataSet. How can I do that?
Example:
CdRsc = "001"
Name = "XPTO"
Pwd = "****"

CdRsc = "002"
Name = "OTPX"
Pwd = "****"

etc, etc...
NOTE: I don't have any DB associated, and it must be this way.


Thanks,
ruca

Re: Add Rows by Miha

Miha
Fri Feb 06 05:41:44 CST 2004

Hi ruca,

There are many ways, two of them:
table.Rows.Add(new object(){field1, field2, ...})
or
DataRow newRow = table.NewRow()
newRow("column1") = 1
...
table.Rows.Add(newRow)

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"ruca" <ruuca@iol.pt> wrote in message
news:OM$XkGK7DHA.3704@tk2msftngp13.phx.gbl...
> Hi,
>
> I have this code:
>
> --------------------------------------------
> Dim myDataSet As DataSet
> myDataSet = New DataSet("Funcionarios")
> ' Create two DataTable objects using a function.
> Dim table As New DataTable()
> Dim col as DataColumn
> Dim data, dia, mes, ano as String
> Dim horas as Date
> Dim strValor as Date
>
>
> 'Adicionar três colunas
> col = New DataColumn ("CdRcs", System.Type.GetType("System.String"))
> table.Columns.Add(col)
> col = New DataColumn ("Name", System.Type.GetType("System.String"))
> table.Columns.Add(col)
> col = New DataColumn ("Pwd", System.Type.GetType("System.String"))
> table.Columns.Add(col)
>
> myDataSet.Tables.Add(table)
> Console.WriteLine(myDataSet.DataSetName, myDataSet.Tables.Count)
> --------------------------------------------
>
> Now I want to add some rows to myDataSet. How can I do that?
> Example:
> CdRsc = "001"
> Name = "XPTO"
> Pwd = "****"
>
> CdRsc = "002"
> Name = "OTPX"
> Pwd = "****"
>
> etc, etc...
> NOTE: I don't have any DB associated, and it must be this way.
>
>
> Thanks,
> ruca
>
>
>
>