Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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: -

Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 5228 times
Author:
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
Related Articles:
Related Interview Questions: