Create DataTable From SQL Query in C#

December 18, 2013 // In: C#

DataTable is most commonly used for Data binding. You may need to generate DataTable many times in the whole project. The best practice is to create a method.

create datatable from sql query c sharp

In this tutorial, we are going to code a method getDataTable . Lets Start!

Namespaces required for methods

Namesapce System.Data  is required for DataTable, and System.Data.SqlClient is required for SqlDataAdapter

Get DataTable from SQL Query.

You need to pass query in parameter and it returns DataTable



Find string in an Array (C#)