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

             .Open()

      EndWith

  • 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 ()

EndWith

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

Do while objReader.Read ()

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

Loop

  • Do not forget to close the connection object.

objConnection.close*();


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



http://
http://www.questpond.com/

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
http://www.xpode.com/Print.aspx?Articleid=694

Click here to go on website