Click here to Skip to main content
Rate this: bad
good
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 2:57am
Edited 16-Oct-12 12:38pm
Maciej Los152.3K
v2
Comments
Toniyo Jackson at 16-Oct-12 8:02am
   
Are you saying that you have to use states instead of States?
n.podbielski at 16-Oct-12 14:56pm
   
Then just use keyword AS.
Maciej Los at 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 at 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
0 OriginalGriff 565
1 Maciej Los 319
2 Richard MacCutchan 220
3 BillWoodruff 164
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2014
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