---
title: "DataTable"  
description: "DataTable is used to store data in memory in SQL database. DataTable contains a collection of constraints .in data base datatable is a collection of r"  
author: "Amit Singh"  
published: 2010-09-01  
updated: 2017-11-30  
canonical: https://www.mindstick.com/articles/122/datatable  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# DataTable

DataTable is used to store data in memory in SQL database. DataTable contains a collection of constraints .in data base datatable is a collection of rows and columns. Datatable is ideal for this purpose, as you can take objects from memory and display the results in controls such as DataGridView in Windows Forms. Here are the simply c sharp example which shows DataTable\

##### Below are the examples which shows about DataTable

```
//these lines are for creating a new connection by passing server name,uid,password and name of the database as here mind.  SqlConnection con = new SqlConnection("server=abc-pc1\\sqlexpress; uid=sa; password=sa; database=mind");//open connection       con.Open();//create a data adapter and invoking the command.SqlDataAdapter ad = new SqlDataAdapter("select * from Employee", con);DataSet ds=new DataSet();ad.Fill(ds,"Employee");//Creating a Datatable objectDataTable dt = new DataTable();               dt = ds.Tables["Employee"]; //  close the coonection Con.close();
```

---

Original Source: https://www.mindstick.com/articles/122/datatable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
