Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here I can't find out the Error. Plz help me .


Here Is My .cs Code page
C#
protected void grvAuthor_SelectedIndexChanged(object sender, EventArgs e)
   {
       Label lblID = (Label)grvAuthor.Rows[grvAuthor.SelectedIndex].FindControl("Label1");
       SqlDataReader dr = helperclass.fillAllData("Select * from RACKDETAILS where RACKID='"+lblID.Text+"'");
       if (dr.Read())
       {
           txtRackId.Text = dr["RACKID"].ToString();
           txtRackName.Text = dr["RACKNAME"].ToString();
           txtRackRemarks.Text = dr["REMARKS"].ToString();
       }
       else
       {
           ScriptManager.RegisterStartupScript(this.Page, typeof(string), "", "alert('Error in Connection...');", true);
       }

   }


Here My .cs Class Code
C#
public static SqlDataReader fillAllData(string query)
    {
        SqlDataReader dr = null;
        using (SqlConnection con = new SqlConnection(helperclass.constring))
        {
            SqlCommand cmd = new SqlCommand(query, con);
            if (con.State == ConnectionState.Closed)
                con.Open();
            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return dr;
            
        }
    }


Thanks in advancce.
Posted
Updated 14-Sep-15 3:16am
v2
Comments
Thanks7872 14-Sep-15 9:18am    
Have you searched Google? See this : About 8,820 results (0.40 seconds)
bigyan sahoo 14-Sep-15 9:23am    
I searched a lot, but in my code I can't find out where is the error.
Thanks7872 14-Sep-15 9:32am    
Did you come across this : http://stackoverflow.com/a/20470000?

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