Click here to Skip to main content
12,398,225 members (56,894 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# MySQL
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:
Select * from states
name of the result table should call “States”

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

[edit]Tags updated - Maciej Los[/edit]
Posted 16-Oct-12 1:57am
Updated 16-Oct-12 11:38am
Maciej Los221.8K
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100