how to get database table name for each field in datatable

I know how to get the name of a field within a DataTable:


How do I get the database Table name (not the DataTable.TableName)?

  • Destination of Team Foundation Server Databases
  • Is checking for primary key value before insert faster than using try-catch?
  • Trigger to insert values in table2, when values are inserted in table1
  • How do you unit test your T-SQL
  • SQL Table with parent and child nodes (navigation table)
  • What happens to the primary key Id when it goes over the limit?
  • MS SQL Insert into concat
  • AWS Lambda - Unable to connect to SQL Server RDS in VPC
  • find records from previous x days?
  • Is there any tool to see the queries run against the database?
  • Entity Framework Code First: How to map SQL Server's computed columns into CF model?
  • How to execute trigger after import?
  • 2 Solutions collect form web for “how to get database table name for each field in datatable”

    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

    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 =

    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");
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.