Click here to Skip to main content
15,908,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
try
        {
            bool check = ValidStudent(TBRNo.Text);

//after executing above statement program jumps up to the catch block n raise d exception

            if (check == false)
            {
                SqlDataReader dr = FetchDetails_frmString(TBRNo.Text);
                DataTable dt = new DataTable();
                
                dt.Load(dr);
                Session["dr"] = dr;
                Session["FetchDetails_frmString"] = dt;
                con.Close();
                if (dt.Rows.Count > 0)
                {
                    string ip = GetIpAddress();
                    int i = StoreIpAddress(ip, TBRNo.Text);
                    if (i > 0)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "Onload", "alert('Login Successful!')", true);
                        Response.Redirect("~/Student/home.aspx");
                    }
                    else
                    { 
                        
                    }
                   
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "Onload", "alert('Access Denied.....This string does not exist')", true);
                }
            }
           else
            {
                ClientScript.RegisterStartupScript(GetType(), "Onload", "alert('You have Already login this Website')", true);
            }
        }
        catch (Exception o)
        {
            Label8.Text = o.Message;
            ClientScript.RegisterStartupScript(GetType(), "Onload", "alert('Access Denied.....Some Problem occured')", true);
        }
        finally 
        { 
            con.Close();         
        }
Posted
Updated 30-Jan-12 22:14pm
v2
Comments
Anuja Pawar Indore 31-Jan-12 4:14am    
Added pre tag

look like Problem is in ValidStudent() function not in this code
 
Share this answer
 
v2
Hi,
you need to publish
C#
ValidStudent(TBRNo.Text);

funtion instead of others.

for a help can you check your array index is negative or less than expected.
C#
array.length=5;
if index < array.length
return array[index]


like that. i think you need to fix it inside the ValidStudent(TBRNo.Text);
or when you assign the return to the bool. Just check it and you get fix.
good luck.
 
Share this answer
 
The number entered in the TBRNo textbox is more than the number of record in the array/dataset/table etc. Thats why your are getting this exception.
 
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