Need to get empty datatable in .net with database table schema

前端 未结 10 863
闹比i
闹比i 2021-02-07 04:40

What is the best way to create an Empty DataTable object with the schema of a sql server table?

10条回答
  •  猫巷女王i
    2021-02-07 05:17

    Assuming that you can connect to the SQL database which contains the table you want to copy at the point it time you want to do this, you could use a conventional resultset to datatable conversion, using

    select * from  where 1=2
    

    as your source query.

    This will return an empty result set with the structure of the source table.

提交回复
热议问题