When I Fill a DataSet, Can I control the string names of the tables?

I would like to be able to access the table from my DataSet using either
(a) a name I specify or
(b) the name of the table the data is coming from

but for some reason C# 2005 is defaulting me to "Table".

Ideas?

           DataTable testTable = new DataTable("MYTABLE");
            DataSet allData = new DataSet("allData");

            //Why does this come back as "Table" instead of FCDET?
            SqlCommand sqlCommand = new SqlCommand("SELECT * from FCDET;", conn);
            SqlDataAdapter sqlAdapt = new SqlDataAdapter(sqlCommand);

           
            sqlAdapt.FillSchema(allData, SchemaType.Source);
            sqlAdapt.Fill(allData);
            testTable = allData.Tables[0];
gurteenAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
Hi gurteen,

Change
> sqlAdapt.Fill(allData);

to
sqlAdapt.Fill(allData, "YourNewTableName");

Cheers!
0
 
GENTPCommented:
also to access the table

DataTable myDataTable = allData.Tables["YourNewTableName"];
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.