elham deljooei

elham deljooei

  • NA
  • 84
  • 73.2k

How to get a row from Sqldatareader in 3-tier?

Jul 31 2013 5:25 AM
Hi everyone
I've had a problem. I want to know how to get a row from sqldatareader in 3-tier?
My code don't run. Could you tell me Why it isn't correct ?
this is my code:
DAL:
 public static SqlDataReader Clerk_Search(string name, string family, string melliCode)
        {
            SqlDataReader sqlDataReader;
            SqlCommand comm = new SqlCommand("Clerk_Search", Data_Access.conn);
            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.AddWithValue("@clk_Name", name);
            comm.Parameters.AddWithValue("@clk_Family", family);
            comm.Parameters.AddWithValue("@clk_MeliCod", melliCode);
            conn.Open();
            sqlDataReader = comm.ExecuteReader();
            conn.Close();
            return sqlDataReader;


        }
BL:
 static public System.Data.SqlClient.SqlDataReader   Clerk_Search(string name, string family, string meliCode)
        {
            System.Data.SqlClient.SqlDataReader sqlDataReader;
          sqlDataReader = Data_Access.Clerk_Search(name, family, meliCode);
          return sqlDataReader;
           
            
        }
UI
 private void Clerk_Search_Click(object sender, EventArgs e)
        {
            //System.Data.SqlClient.SqlDataReader sqlDataReader;
           
           
                System.Data.SqlClient.SqlDataReader red;
                red = Business.Clerk_Search(txtNameClerk.Text.Trim(), txtFamilyClerk.Text.Trim(), txtShomarehyeMeliClerk.Text.Trim());
                txtClerkId.Text = red["clk_Id"].ToString();
          
        }

Answers (9)