Link to home
Start Free TrialLog in
Avatar of Abhilash Nagar
Abhilash Nagar

asked on

SQLDataReader giving only one field

Hello,
Anything incorrect below as i am getting only single field rather then 3 in the datareader. I am just getting StudentID field value only.

SqlCommand getStudent = InitiateDatabaseCommand();

            getStudent.Parameters.Add("@StudentId", SqlDbType.Int);
            getStudent.Parameters["@StudentId"].Value = 1;
            getStudent.CommandText = "Select * From Student  r where r.StudentID=@StudentId AND r.Name like '%R%'";

            SqlDataReader dr = comm.ExecuteReader();

        while (dr.Read()){

           //filling the studentinfo data model object here.
        }
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

//filling the studentinfo data model object here.

You omitted the most significant piece of information from your question. Could you please demonstrate what is it that is being written where you have mentioned the above text?

Also, please show us the structure of the Student table.
ASKER CERTIFIED SOLUTION
Avatar of Abhilash Nagar
Abhilash Nagar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abhilash Nagar
Abhilash Nagar

ASKER

I was referring a command object which was incorrect.

Correct command object was SqlCommand comm

I was referring to the SqlCommand testcomm which was running execute scalar.

Thanks for all the responses. Really appreciate your time.