Add Rows

R

ruca

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
 
M

Miha Markic [MVP C#]

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top