Click here to Skip to main content
15,884,425 members
Home / Discussions / C#
   

C#

 
AnswerRe: MouseDown Event? Pin
OriginalGriff6-May-09 0:00
mveOriginalGriff6-May-09 0:00 
GeneralRe: MouseDown Event? Pin
Megidolaon7-May-09 20:51
Megidolaon7-May-09 20:51 
GeneralRe: MouseDown Event? Pin
OriginalGriff7-May-09 21:58
mveOriginalGriff7-May-09 21:58 
AnswerRe: MouseDown Event? Pin
Member 3046636-May-09 6:54
Member 3046636-May-09 6:54 
QuestionExporting excel to pdf Pin
tauras815-May-09 23:15
tauras815-May-09 23:15 
AnswerRe: Exporting excel to pdf Pin
Mycroft Holmes5-May-09 23:26
professionalMycroft Holmes5-May-09 23:26 
GeneralRe: Exporting excel to pdf Pin
tauras816-May-09 0:14
tauras816-May-09 0:14 
QuestionInvalid attempt to call MetaData when reader is closed. Pin
Vimalsoft(Pty) Ltd5-May-09 23:10
professionalVimalsoft(Pty) Ltd5-May-09 23:10 
Good Day All

I have the Following Code in my DAL

public SqlDataReader  Get_Staff_Cycles_internal(String DB)
       {

           SqlDataReader rd = null;

           strcon = GetConnectionString(DB);

           con = new SqlConnection(strcon);

           cmdselect = new SqlCommand();

           cmdselect.CommandType = CommandType.StoredProcedure;

           cmdselect.CommandText = "[dbo].[sp_Get_Staff_Cycles_internal]";

           cmdselect.CommandTimeout = 0;

           cmdselect.Connection = con;

           try
           {
               con.Open();

               rd = cmdselect.ExecuteReader(CommandBehavior.CloseConnection);

           }
           catch (SqlException)
           {
               throw;
           }
           finally
           {
               if (con != null)
               {
                   con.Close();

               }
           }
           return rd;
       }


and Am using this code Like this In BLL

public SqlDataReader Get_Staff_Cycles(int ACTIVITY_ID, String DB)
       {
           DAL.DAL obj = new DAL.DAL();

           SqlDataReader rd = null;

           try
           {
               obj.Get_Staff_Cycles(ACTIVITY_ID, DB);

               rd = obj.Get_Staff_Cycles_internal(DB);

           }
           catch (SqlException)
           {
               throw;
           }
           finally
           {
               obj = null;

           }
           return rd;

       }


And am Calling it like this in PL(Presentation Layer)

private void Bind_Grid_For_Staff()
    {
        SqlDataReader rd = null;

        BLL.BLL obj = new BLL.BLL();

        try
        {
            if (Convert.ToString(Session["Selected_ID_Bind"]).Length > 6)
            {
                //If the Activities are multiselect

          String Activityid = Convert.ToString(Session["Selected_ID_Bind"]);

                    if (Activityid != null || Activityid != "")
                    {

              ArrayList Final_String = (ArrayList)Fixed_String_Multi(Activityid);

                        for (int i = 0; i < Final_String.Count; i++)
                        {
                            rd = obj.Get_Staff_Cycles(Convert.ToInt32(Final_String[i]), Convert.ToString(Session["ActiveDatabase"]));
                        }

                        if (rd != null)
                        {
                            while (rd.Read())
                            {

                                Gridstaff.DataSourceID = null;
                                Gridstaff.DataSource = rd;
                                Gridstaff.DataBind();
                            }
                        }
                    }
                    else
                    {
                        lblGridStaff.Text = "Could not Bind StaffGrid";
                        lblGridStaff.ForeColor = System.Drawing.Color.Red;
                    }
                


            }
            else
            {
                if (Convert.ToString(Session["Selected_ID_Bind"]) != null)
                {

                    String Activityid = Convert.ToString(Session["Selected_ID_Bind"]);

                    if (Activityid != null || Activityid != "")
                    {

                        ArrayList Final_String = (Fixed_String(Activityid));

                        for (int d = 0; d < Final_String.Count; d++)
                        {
                            rd = obj.Get_Staff_Cycles(Convert.ToInt32(Final_String[d]), Convert.ToString(Session["ActiveDatabase"]));
                        }
                   
                        if (rd != null)
                        {
                                
                                Gridstaff.DataSource = rd;
                                
                                Gridstaff.DataBind();
                                
                                rd.Close();
                            
                        }
                    }
                    else
                    {
                        lblGridStaff.Text = "Could not Bind StaffGrid";
                        lblGridStaff.ForeColor = System.Drawing.Color.Red;

                    }
                }
                else
                {
                    Response.Redirect("SubjectStaff.aspx", false);
                }
            }
        }
        catch (ApplicationException e)
        {
            lblStatus.Text = e.Message.ToString();
        }
    }


i get an Error

Invalid attempt to call MetaData when reader is closed.


and its Poiting to the part that Binds the gridview here

Gridstaff.DataBind();


Thank you

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: Invalid attempt to call MetaData when reader is closed. Pin
Mycroft Holmes5-May-09 23:24
professionalMycroft Holmes5-May-09 23:24 
GeneralRe: Invalid attempt to call MetaData when reader is closed. Pin
Vimalsoft(Pty) Ltd5-May-09 23:37
professionalVimalsoft(Pty) Ltd5-May-09 23:37 
GeneralRe: Invalid attempt to call MetaData when reader is closed. Pin
Mycroft Holmes6-May-09 14:16
professionalMycroft Holmes6-May-09 14:16 
GeneralRe: Invalid attempt to call MetaData when reader is closed. Pin
Vimalsoft(Pty) Ltd7-May-09 3:08
professionalVimalsoft(Pty) Ltd7-May-09 3:08 
QuestionThe process cannot access the file '' because it is being used by another process Pin
Member 39664155-May-09 22:59
Member 39664155-May-09 22:59 
AnswerRe: The process cannot access the file '' because it is being used by another process Pin
Mycroft Holmes5-May-09 23:19
professionalMycroft Holmes5-May-09 23:19 
GeneralRe: The process cannot access the file '' because it is being used by another process Pin
ToolMaker20078-May-09 0:58
ToolMaker20078-May-09 0:58 
GeneralRe: The process cannot access the file '' because it is being used by another process Pin
ToolMaker20078-May-09 1:06
ToolMaker20078-May-09 1:06 
AnswerRe: The process cannot access the file '' because it is being used by another process Pin
Member 33520014-Aug-10 21:45
Member 33520014-Aug-10 21:45 
Questionwith out exponent value need in float Pin
Member 38798815-May-09 22:58
Member 38798815-May-09 22:58 
AnswerRe: with out exponent value need in float Pin
OriginalGriff5-May-09 23:19
mveOriginalGriff5-May-09 23:19 
QuestionSqlBulkCopy that can do UPDATE Pin
lakhwinder.ghuman5-May-09 22:00
lakhwinder.ghuman5-May-09 22:00 
AnswerRe: SqlBulkCopy that can do UPDATE Pin
Mycroft Holmes5-May-09 22:27
professionalMycroft Holmes5-May-09 22:27 
AnswerRe: SqlBulkCopy that can do UPDATE Pin
Member 33520014-Aug-10 21:47
Member 33520014-Aug-10 21:47 
QuestionHmm... External Methods? Pin
jas0n235-May-09 21:47
jas0n235-May-09 21:47 
AnswerRe: Hmm... External Methods? Pin
Pete O'Hanlon5-May-09 22:18
mvePete O'Hanlon5-May-09 22:18 
GeneralRe: Hmm... External Methods? Pin
jas0n236-May-09 0:45
jas0n236-May-09 0:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.