Runtime Array and DataTable with VB.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

I have 5 string in my array that I get from MS Access DB.
Public mDov(0) as string and I fill with my for loop. The result as shown
below

mDov(0) = "ABC_01"
mDov(1) = "ABC_02"
mDov(2) = "ABC_03"
mDov(3) = "ABC_04"
mDov(4) = "ABC_05"

Now I need to create 5 Public type DataTable and the each table name based
on the above strings.

How to I create in runtime 5 DataTable (in future might be more) as:

Public Shared tbl_ABC_01 as DataTable
Public Shared tbl_ABC_02 as DataTable
Public Shared tbl_ABC_03 as DataTable
Public Shared tbl_ABC_04 as DataTable
Public Shared tbl_ABC_05 as DataTable

As you can see the Table name came from above array.

I also need to crate runtime string array and each array name based on the
above strings. But I don't know how?

I appricate your kind help and reading my post.

Thank you.

Rgds,
Niyazi
 
Hi Niyazi,

If you don't know how many tables and their names at design time, then you
cann not code it the way you want. You could have an array of datatables,
with a number of items that is determinded at runtime. For example :

declaration like this:
Public shared tblABC() as datatable

dimensios assigned like this, after mDov is retrieved from your database:
ReDim tblABC(mDov.GetLength(0)-1)

Hope this helps,

Joris
 
Hi Joris,

Sorry for my late post. I had some busy schedule with family. I thank you
for your kind help an yes it did the job that I was looking for.

Thank you.

Rgds,
GC
 
Back
Top