Turning a SqlCommand with parameters into a DataTable

前端 未结 2 387
Happy的楠姐
Happy的楠姐 2020-12-05 06:37

I\'m adapting some code that someone else wrote and need to return a DataTable for time\'s sake.

I have code like this:

using (SqlCommand command = n         


        
2条回答
  •  天命终不由人
    2020-12-05 07:02

    By using a DBDataAdapter

    excerpt from ms documentation

    // Create the DbDataAdapter.
    DbDataAdapter adapter = new DbDataAdapter();
    adapter.SelectCommand = command;
    
    // Fill the DataTable.
    DataTable table = new DataTable();
    adapter.Fill(table);
    

提交回复
热议问题