Introduction:-
Here I have explained How to retrieve data using linq query stored in DataTable
in asp.net.
Description:-
In my previous article I have explained How to retrieve data using linq query in DataTable ,Join More Than Three Tables using Linq Query ,EDITING,UPDATING AND DELETING DATA IN THE FORM USING LINQ TO SQL ,FETCHING DATA FROM DATABASE AND POPULATING FIELDS IN THE FORM USING LINQ TO SQL ,INSERTINGDATA TO DATABASE USING LINQ TO SQL ,INSERTING DATA TO DATABASE USING LINQ TO SQL .
In this Article I will explain how to store
data into datatable using linq query in asp.net.I have used here data context
class and by creating the object of that class we can get the tables present
inside that object.
To store the data into datatable follow the
below steps.
ShibashishDataClassesDataContext dc = new ShibashishDataClassesDataContext();
var x = from n in
dc.Table1 select n;
IDbCommand cmd = dc.GetCommand(x);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
DataTable dt = new DataTable();
cmd.Connection.Open();
adapter.FillSchema(dt, SchemaType.Source);
adapter.Fill(dt);
Like this you can store your data into datatable.If you want to learn more about linq query then go to this links
http://www.dotnetocean.com/2013/03/how-to-retrieve-data-using-linq-query.html,http://www.dotnetocean.com/2012/07/join-more-than-three-tables-using-linq.html,http://www.dotnetocean.com/2012/05/editing-updating-and-deleting-data-in.html,http://www.dotnetocean.com/2012/05/fetching-data-from-database-and.html,http://www.dotnetocean.com/2012/05/inserting-data-to-database-using-linq_03.html,http://www.dotnetocean.com/2012/05/inserting-data-to-database-using-linq.html
Keep coding...
Thanks Shibashish Mohanty
No comments:
Post a Comment
Please don't spam, spam comments is not allowed here.