How to querying in ADO.Net, when using SqlCommand?

How to querying in ADO.Net, when using SqlCommand?

Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);
Call Execute reader to get query results
SqlDataReader rdr = cmd.ExecuteReader(); 
Passing the command string and connection object to the constructor.  Then we obtain a SqlDataReader object by calling the ExecuteReader method of the SqlCommand object, cmd.

By:Aditya
Date:2028-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related ADO.NET Subjective Links

ADO.NET Subjective interview questions and answers for experienced and fresher