Xpode.com        Click here to Print this article.

ADO.NET interview questions: - How can we fire a simple SQL Statement using ADO.NET?

  • First imports the namespace “System.Data.SqlClient”.
  • Create a connection object and call the “Open” function.

      With objConnection

             .Connection String = strConnectionString



  • Create the command object with the SQL. Also, assign the created connection object to command object and execute the reader.

ObjCommand = New SqlCommand (“Select First Name from Employees”)

With objCommand

                .Connection = objConnection

                Breeder = .Execute Reader ()


  • You can then loop through the reader object to read the data.

Do while objReader.Read ()

lstData.Items.Add (objReader.Item (“First Name”))


  • Do not forget to close the connection object.


Above is the ADO.NET interview questions and see following SQL video on triggers, inserted and deleted tables: -


Contributed by:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers

Resourse address on xpode.com

Click here to go on website