I've fixed these problem and today in a position to place data towards the table.
Now while reading through the information with Title, Age, Gender,City, TypeofDisease condition not receiving the end result..consequently always I am getting "System.Data.SqlClient.SqlDataReader" Here's my saved procedure:

CREATE PROCEDURE SearchPatient
(
@Name varchar(50),
@Age int,
@Gender varchar(50),
@City varchar(50),
@TypeofDisease varchar(50)
)
 AS
select * from Patient where Name=@Name and Age=@Age and Gender=@Gender and City=@City and TypeofDisease=@TypeofDisease
GO

Here is my event code:

protected void BtnSearch_Click(object sender, EventArgs e)
    { 
        string name = TxtName.Text.Trim();
        int age = Convert.ToInt32(TxtAge.Text);
        string gender;
        if (RadioButtonMale.Checked)
        {
            gender = RadioButtonMale.Text;
        }
        else
        {
            gender = RadioButtonFemale.Text;
        }
        string city = DropDownListCity.SelectedItem.Value;

        string typeofdisease = "";
        foreach (ListItem li in CheckBoxListDisease.Items)
        {
            if (li.Selected)
            {
                typeofdisease += li.Value;
            }
        }
        string[] sl=typeofdisease.Split();
        foreach (string s in sl)
        {
            ListItem itm = CheckBoxListDisease.Items.FindByValue(s);
            if (itm != null)
            {
                itm.Selected = true;
            }
        }
        string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
        SqlConnection con = new SqlConnection(ConString);
        con.Open();
        SqlCommand com = new SqlCommand("SearchPatient", con);
        com.CommandType = CommandType.StoredProcedure;
        try
        {
            com.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = name;
            com.Parameters.Add("@Age", SqlDbType.Int).Value = age;
            com.Parameters.Add("@Gender", SqlDbType.VarChar, 50).Value = gender;
            com.Parameters.Add("@City", SqlDbType.VarChar, 50).Value = city;
            com.Parameters.Add("@TypeofDisease", SqlDbType.VarChar, 50).Value = sl.ToString();
            SqlDataReader dr;
            dr = com.ExecuteReader();
            StringBuilder sb = new StringBuilder();
            sb.Append(dr);
            lblPatientDetails.Text = sb.ToString();          
        }
        catch
        {

            throw;
        }
        finally
        {
            con.Close();
            com.Dispose();
        }
    }

Please somebody modify my code, to attain my expected result..

You should utilize techniques from dr, the SqlDataReader. For instance

  • dr.GetValue() (To obtain a given column in the current row)
  • dr.GetValues() (To obtain all values from current row)
  • dr.NextResult() (to get at the following row of information within the resultset)

The reasons you keep getting "System.Data.SqlClient.SqlDataReader" rather than some outcome is that setting dr to some string (by means of StringBuilder.Append) uses, unconditionally, the ToString() approach to this object which produces this specific string (a helpful debug feature, but otherwise not so relevant one).

 dr = com.ExecuteReader();
 StringBuilder sb = new StringBuilder();
 sb.Append(dr);
 lblPatientDetails.Text = sb.ToString();  

Switch to :

using(SqlDataReader rdr = com.ExecuteReader())
{
     if(rdr.HasRows)
     {
       while(rdr.Read())
       {
        sb.Append(rdr.GetString(0)); 
        ..... etc
       }
     }
}

Or create DataSet.

    using (SqlDataAdapter dataAdapter = new SqlDataAdapter(com))
    {
        DataSet dataSet = new DataSet();
        dataAdapter.Fill(dataSet);
        return dataSet;
    }