473,503 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Datatable Question

Can someone please tell me how I add information to a datatable!

I already have some information that has been pulled from an Active
Directory Database but I want to add additional information from an SQL
Server Database...

How do I achieve this???

Thanks

Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("contacts")
tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Name", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Dept.", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Ext", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Email", System.Type.GetType("System.String"))
ds.Tables.Add(tbcontacts)

End Sub
Nov 19 '05 #1
3 995
You want to add DataRows in DataTable which is created in your sample code?

I have always added rows like this (C#)

tbcontacts.Rows.Add(new object[]{[column 1 value], [column 2
value],...[column n value]})



"Tim::.." wrote:
Can someone please tell me how I add information to a datatable!

I already have some information that has been pulled from an Active
Directory Database but I want to add additional information from an SQL
Server Database...

How do I achieve this???

Thanks

Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("contacts")
tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Name", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Dept.", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Ext", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Email", System.Type.GetType("System.String"))
ds.Tables.Add(tbcontacts)

End Sub

Nov 19 '05 #2
Thanks... but not exactly what I wanted to know!

I have a database and usually use a data reader to access info from a
database but I want to add aditional info to an existing datatable...

Any ideas???

"Jouni Karppinen" wrote:
You want to add DataRows in DataTable which is created in your sample code?

I have always added rows like this (C#)

tbcontacts.Rows.Add(new object[]{[column 1 value], [column 2
value],...[column n value]})



"Tim::.." wrote:
Can someone please tell me how I add information to a datatable!

I already have some information that has been pulled from an Active
Directory Database but I want to add additional information from an SQL
Server Database...

How do I achieve this???

Thanks

Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("contacts")
tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Name", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Dept.", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Ext", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Email", System.Type.GetType("System.String"))
ds.Tables.Add(tbcontacts)

End Sub

Nov 19 '05 #3
Why not just pull the data from the database into a 2nd datable, and then
copy all the rows from this new datatable to the tbContacts one?

you can do this something like:
for i as integer = 0 to databaseTable.Rows.Count - 1
tbContacts.Rows.Add(databaseTable.Rows(i).ItemArra y)
next

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:9D**********************************@microsof t.com...
Can someone please tell me how I add information to a datatable!

I already have some information that has been pulled from an Active
Directory Database but I want to add additional information from an SQL
Server Database...

How do I achieve this???

Thanks

Private Sub createTable()
Dim tbcontacts As DataTable = New DataTable("contacts")
tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Name",
System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Dept.",
System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Ext", System.Type.GetType("System.String"))
tbcontacts.Columns.Add("Email",
System.Type.GetType("System.String"))
ds.Tables.Add(tbcontacts)

End Sub

Nov 19 '05 #4

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

Similar topics

5
3063
by: Will | last post by:
I've got a simple form that collects data from a user and I want to display that data in a sortable grid or table. The nature of this data is rather temporary, so there's no need to persist it to a...
0
7534
by: Tal Sharfi | last post by:
Hi everyone I recently had the need for StringGrid object same as the one that Delphi has. An object that helps show lists of other objects in a simple grid. I searched the news groups and...
3
1746
by: John Baker | last post by:
Hi:7 Newby here to ASP, and using the ASP.NET Web Matrix development tool. While that tool looks great for a Newby, I have run into a snag. I have an HTML Text Box which I have named HireInput,...
13
1839
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql...
2
2273
by: Eniac | last post by:
*argh* ... *pull hairs* I've recently started developing from ASP to ASP.NET The switch was fairly smooth since i had done some VB.net before ... then came...FORMS! :) I find it astounding...
10
1369
by: Nemisis | last post by:
HI everyone, I think i am on the right path but if someone could confirm it, that would be great. In my business Layer i have my business object, for this example, called User. User has...
1
2108
by: Phillip Vong | last post by:
Newbie here trying to learn. Using VS2005 / learning in VB.NET for an ASPX page. Sorry for this simple question. I have a Gridview1 with 2 columns. I added a 3rd column and all I want to do...
6
1268
by: Arne Beruldsen | last post by:
I have a very simple Access data base. No new info is going to be added...the only changes are to existing fields. I have 2 tables both with one row each. I'm using vb.net. I can easily...
5
5878
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.