473,671 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create datatable at runtime

Hi Group,
i'd like to create 10 datatables at runtime
something like this

for (int i=1; i<11;i++)
{
DataTable i.ToString() = new DataTable()
}

How can I do it?

TIA

Peter
Nov 15 '05 #1
2 12324
You can create a dataset:

DataSet ds = new DataSet();

then in the loop:

for (int i = 1; i<11; i++)
{
ds.Tables.Add(i .ToString()); //Not sure of line of code, but should be
something like it.
....
}

Hope this helps.
"LPeter" <no****@nospam. local> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
Hi Group,
i'd like to create 10 datatables at runtime
something like this

for (int i=1; i<11;i++)
{
DataTable i.ToString() = new DataTable()
}

How can I do it?

TIA

Peter

Nov 15 '05 #2
Hi Melih,
your trick works very well

Thank you
Peter

"Melih Odabaþ" <me**********@y ahoo.com (no spam)> wrote in message
news:eT******** *******@tk2msft ngp13.phx.gbl.. .
You can create a dataset:

DataSet ds = new DataSet();

then in the loop:

for (int i = 1; i<11; i++)
{
ds.Tables.Add(i .ToString()); //Not sure of line of code, but should be
something like it.
...
}

Hope this helps.
"LPeter" <no****@nospam. local> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
Hi Group,
i'd like to create 10 datatables at runtime
something like this

for (int i=1; i<11;i++)
{
DataTable i.ToString() = new DataTable()
}

How can I do it?

TIA

Peter


Nov 15 '05 #3

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

Similar topics

4
2106
by: David K | last post by:
we are having a problem when trying to serilalize and deserialize DataTable When replacing the container to be ListArray or HashTable everything works fine The code is very straight forward ( see below), however when comparing the DataTable before and after the serialize, it is not the same The DataTable after the serialization contains only the string of class type ( Vclass in this class) but not the class itself Any idea ?
5
1911
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2; // ... public static MyObject Object400;
0
1839
by: Bill Toulias | last post by:
I want to be able to display the tuples of a select query (which may change at runtime, so no prior knowledge for column characteristics) and edit them as well. I used this code, that executes the select, gets schema from the datareader, creates a table that can host data of that type, fills it with data from the datareader and then binds it to a DataGrid. The problem is that although i seem to do everything correctly and although all...
1
1846
by: Bruno Pimentel Machado | last post by:
is it possible (how) to build a asp.net page on the fly? i.e.: I have a db with the controls I want to add to it: 1. TextBox - name "ABC" - Text "CDE" - Left 10 - Top - 30 2. Button - name "BT1" - Text "TXT" - Left 30 - Top 100 I have the following issue... I am trying to build a simple CRM tool... - I've done this before in VB (Client-Server) - and I thought it would be great in asp.net (c#)... so far - no problem...
7
2207
by: Dave Taylor | last post by:
I have a DataTable with three string columns, "Value", "Format" and "Type" However, some of the rows contain numbers and dates in the Value field. So I would like to be able to format the output based on the format specifier in the Format field. The problem is, since the Value field is a string, it doesnt properly "format". So I need to convert to an object of the type specified by "Type"...ok, so Activator.CreateInstance() BUT the...
11
19712
by: Bruce D | last post by:
I have a DataTable that I need to merge the 'lastname' and 'firstname' fields to be displayed in a datagrid. I know I can use the SQL statement to merge the fields into one, but I want to know if it's possible to do through the DataTable, DataView or DataGrid that I have already created to display the data. This should be easy...right? -bruce duncan
10
4942
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
1
1860
by: conckrish | last post by:
Hi all, Can anyone tell me how to find out the memory used by a DataTable at runtime? I am appending lot of data to datatable at runtime.I have to measure this memory comsumption programatically... Plz help me... Thanx in advance... Jacob...
5
1555
by: bz | last post by:
Hi, I create a class that retrieves a number of records from database. Internally, the class store the returned data in a datatable / datareader. I would like to bind a listbox to that class (to the records from this datatable), using data binding wizard and to be able to select bind to object How should I make this class to be able to accomplish this? Do I have to define it to implement some interface? Which one? I want to bind...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7441
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6234
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5702
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2058
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.