Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Day
i have used ADO.net to connect and manage data in SQL server and now i knew about Linq and i want to use it but i prefer to do everything by code only,so if you please i want to write the following simple code in the LINQ method:

C#
SqlConnection oConn = new SqlConnection("Data Source = roger\\sqlexpress;Initial Catalog = test; Integrated security=SSPI");
SqlCommand oCmd = new SqlCommand();
SqlDataReader Rdr;
            
oConn.Open();
            
oCmd.Connection = oConn;
oCmd.CommandType = CommandType.Text;
oCmd.CommandText = "select * from person";
            
Rdr = oCmd.ExecuteReader();
while(Rdr.Read())
    MessageBox.Show(Rdr["pin"].ToString());            
oConn.Close();


and i want to know the difference between using ADO and LINQ.
Thanks
Posted
Updated 8-Mar-11 2:06am
v2

1 solution

In ADO.NET you manage connection and CRUD by yourself.
But in LINQ, it creates classes for all objects in Database, in short DataContext.
You need to focus on what to do with Data, rather than how to do.

See http://blogs.msdn.com/b/wriju/archive/2008/07/14/linq-to-sql-vs-ado-net-a-comparison.aspx[^] for detail.
 
Share this answer
 
Comments
Tarun.K.S 8-Mar-11 8:08am    
Perfect link! 5d!
Wild-Programmer 8-Mar-11 8:11am    
Thanks Tarun :)
Rojeh 8-Mar-11 10:14am    
Thanks a lot
this link will really help me
Tarun.K.S 8-Mar-11 13:23pm    
Do keep it as a practice to mark and vote the answers that helped you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900