views:

161

answers:

3

I used a dataset to store 15 tables that I need at the time of loading. When i filled all the tables using stored procedure it returns me all the table but name of the table doesn't comes as that of actual table name in a database.

It takes all the table with table name as Table1, Table2, Table3...

I want them to be with the name as they actually are in table.

SELECT PK_GUEST_TYPE, [DESCRIPTION] FROM L_GUEST_TYPE
SELECT PK_AGE_GROUP_ID, AGE_GROUP FROM L_AGE_GROUP
SELECT PK_COMPANY_ID, COMPANY_NAME FROM M_COMPANY
SELECT PK_COUNTRY_ID, COUNTRY FROM L_COUNTRY
SELECT PK_EYE_COLOR_ID, [DESCRIPTION] FROM L_EYE_COLOR
SELECT PK_GENDER_ID, [DESCRIPTION] FROM L_GENDER
SELECT PK_HAIR_COLOR_ID, [DESCRIPTION] FROM L_HAIR_COLOR
SELECT PK_STATE_PROVONCE_ID, [DESCRIPTION] FROM L_STATE_PROVINCE
SELECT PK_STATUS_ID, [DESCRIPTION] FROM L_STATUS

SELECT PK_TITLE_ID, [DESCRIPTION] FROM L_TITLE
SELECT PK_TOWER_ID, [DESCRIPTION] FROM M_TOWER
SELECT PK_CITY_ID, [DESCRIPTION] FROM L_CITY
SELECT PK_REGISTER_TYPE_ID, [DESCRIPTION] FROM L_REGISTER_TYPE

Here is my frontend coding to fill dataset.

             OpenConnection();
             adp.Fill(ds);
             CloseConnection(true);
A: 

Have the first (or last) table a meta table of table names in the same order as the following (or preceding) tables.

Lloyd
@Lloyd: thx, That could be a solution to the problem that I want right now. But this is not a actual answer. I can see in adp.fill function's overload that it has one of the overload that has datatable array which can map table names but it is looking for other two parameters as well which i dont want to give. i.e. startRow, max records to retrieve
Shantanu Gupta
@Shantanu: Lloyd meant, return meta from your SP(eg: like `SELECT 'L_GUEST_TYPE', 'L_AGE_GROUP'...`) and fill in the `.TableName` property as `ds.Table[0].TableName = ds.Table[nLastTable].Rows[0][0].ToString()`
KMan
+1  A: 

I would have invested time to use typed dataset, makes a lot of things much easier. Remember you probarly will come back to this code in a month or three. :)

Nasit
+2  A: 

Probably this would help Mapping Data Source Tables to Dataset Tables

KMan