Click here to Skip to main content
15,908,444 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

Datareader is used to find the values is exsist or not in the table...need a code for it...
Posted
Comments
rkthiyagarajan 14-Sep-11 5:01am    
Clear your question
Prerak Patel 14-Sep-11 5:05am    
Not clear.

You may use the DataTable.Select[^] method to achieve this behaviour.
 
Share this answer
 
You can use dr.read() or dr.HasRows

SqlCommand myCMD = new SqlCommand("SELECT CategoryID, CategoryName FROM Categories;" +
                                  "SELECT EmployeeID, LastName FROM Employees", nwindConn);
nwindConn.Open();

SqlDataReader myReader = myCMD.ExecuteReader();

do
{
  Console.WriteLine("\t{0}\t{1}", myReader.GetName(0), myReader.GetName(1));

  while (myReader.Read())
    Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));

} while (myReader.NextResult());

myReader.Close();
nwindConn.Close();
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900