Click here to Skip to main content
15,887,450 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I was wondering if I could give names to the tables that are returned in the MYSQL result in order to access them with .NET through their name.

For example the table that returns the states of America must call States:
SQL
Select * from states

name of the result table should call “States”

And I could access the tables in the query’s result like that:
C#
dataSet.Tables["States"];


[edit]Tags updated - Maciej Los[/edit]
Posted
Updated 16-Oct-12 11:38am
v2
Comments
Toniyo Jackson 16-Oct-12 8:02am    
Are you saying that you have to use states instead of States?
n.podbielski 16-Oct-12 14:56pm    
Then just use keyword AS.
Maciej Los 16-Oct-12 18:03pm    
Not clear. If you know from which table you want to get data, where is a problem?

Have you seen this question and onetwitch answer?

1 solution

Please refer this article it has all the answers you need.

http://msdn.microsoft.com/en-us/library/ms810286.aspx[^]

Important: There is no direct way to provide datatable name straight from stored procedure or sql query.
 
Share this answer
 
v2
Comments
Maciej Los 16-Oct-12 18:24pm    
I think OP wants to get the name of table from sql query command and to create a dataset/datatable object with the "name" which is equal to the "name of table".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900