Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
code in DataAccessLayer
C#
public DataSet FindRecord(int RollNumber)
      {

              using (SqlConnection con = new SqlConnection(cs))
              {
                  DataSet ds = new DataSet();
                  SqlCommand cmd = new SqlCommand("spfindtblstudent", con);
                  cmd.Parameters.AddWithValue("@RollNumber", RollNumber);
                  SqlDataAdapter da = new SqlDataAdapter(cmd);
                  cmd.CommandType = CommandType.StoredProcedure;
                  con.Open();
                  da.Fill(ds);
                  con.Close();
                  return ds;

              }
      }
Code in Business Logic Layer

C#
public DataSet Find(int RollNumber)
       {
           DataSet ds = null;
           Dal objdal = new Dal();
           ds = objdal.FindRecord(RollNumber);

           return ds;
       }
Code in Codebehind File

C#
protected void btnfind_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            int RollNumber = Convert.ToInt32(txtid.Text);
            Bll objbll = new Bll();
            objbll.Find(RollNumber);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                txtname.Text = ds.Tables[0].Rows[0]["Name"].ToString();
                txtaddress.Text = ds.Tables[0].Rows[0]["Address"].ToString();
                txtphone.Text = ds.Tables[0].Rows[0]["Phone"].ToString();
            }
            else
            {
                Label1.Text = "No Record(s) avalilable";
            }
no exception no error but not getting retrieved what could be the problem?
Posted
Updated 1-Nov-14 6:54am
v3
Comments
[no name] 1-Nov-14 11:37am    
Please format your code when posting a question...

1 solution

That isn't a question we can answer: it needs your stored procedure, and your database data - and we don't have either, and can't get access to either.

So start by testing your SP in SSMS: run it and see what you get.
Then use the debugger to look at exactly what you are passing to the SP as the value of RollNumber and confirm that works in SSMS before continuing.
Then, look at exactly what information the dataset got in the debugger before looking at what the code that called your C# method is doing with the DataSet when it's returned.

But we can't do any of that!
 
Share this answer
 

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