473,383 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Add Rows to a Table

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
Nov 18 '05 #1
1 1123
Dim row As DataRow = myDataSet.Tables(0).NewRow

row("CdRcs") = value
row("Name") = value
row("Pwd") = value

myDataSet.Tables(0).rows.add(row)

When you create the DataTable you could give it a name in the constructor
like Dim table As New DataTable("MyTable"). That way you can use that
rather than the index value of the Table.

Good luck,
Brian Parlier
"ruca" <ru***@iol.pt> wrote in message
news:ON**************@TK2MSFTNGP09.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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Luis Esteban Valencia | last post by:
Hello I wrote a program with code behind in C# to add row into table dynamically and the program worked very well in .Net Framework 1.1. When I run this program in .Net Framework 2.0 beta...
11
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
3
by: rinu911 | last post by:
hi all I am tring to insert a values to a table by checking if the value is there in the table already but it gives me this error "Query input must contain at least one table or query" ...
8
by: ananthaisin | last post by:
How to reduce the table size for any table while using truncate or delete statements. In oracle 8i it was truncating the storage space but in 10g it is not .... I have given truncate statement in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.