Reputation: 842
I know how to get the name of a field within a DataTable
:
col.ColumnName
How do I get the database Table name (not the DataTable.TableName
)?
Upvotes: 1
Views: 3747
Reputation: 48558
DataTable
is a table in memory. It does not keep track of from which database table it got filled.
Suppose I am using this select statement to fill a DataTable
select * from foo,bar where foo.id = bar.id
Now tell me what should be DataTable name.
What you can do is when filling datatable, give it a table name like this
mydatatable = new DataTable("SomeTableName");
Upvotes: 1
Reputation: 63956
The database table name is not returned in the DataTable
. You should know the table name from the select statement (if a proc, look at the proc code) you used to populate the DataTable
Upvotes: 3