ADO.NET Execute Commands .. When to use what ??

SqlDataAdapters for SqlCommand

A database on a server (example: MySql, msSql, etc) is all accessed by ADO.NET using SqlConnection objects. There are typically four tasks we can perform using SQL which are, selecting queries from database, insert, update and delete. Each having different ADO.NET SqlCommand objects to query the different statements. SqlCommands are mainly divided in two categories, SqlDataAdaptors (disconnected) and SqlDataReaders (Connected). The mostly used SqlDataAdaptors are the: Fill() command, ExecuteScalar(), and ExecuteNonQuery().  For each, an example will be displayed below along with some explanation.

Continue reading

Linq to SQL using Stored Procedures in nThier Design

After doing a lot of research, I realised that when using Linq to Sql to communicate with the database, it is quite impossible or too complicated to use datatables or datarows. In this example I will demonstrate an easy and quick way to retrieve a whole table from a database using stored procedures assuming we are using a three thier design.

Continue reading