Click here to Skip to main content
15,904,935 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
C#
SqlConnection conn = new SqlConnection(Application["CS"].ToString());
SqlCommand cmd = new SqlCommand("select top 1(CMTID),COMMENT,HEADING from FTAB", conn);
        SqlDataReader sdr = cmd.ExecuteReader();
        if (sdr.Read() == true)
        {
            lblHead.Text = sdr["HEADING"].ToString();
        }
        conn.Close();



but its not working showing error :

XML
Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>



I am not able to find error same code running on previous websites, so whats the error here.
Posted
Updated 10-Oct-12 23:12pm
v3
Comments
Sergey Alexandrovich Kryukov 11-Oct-12 3:50am    
First of all, this is not a question. Also, you tagged "ASP.NET", but the code is about ADO.NET. Do you still think this is related to ASP.NET? If so, no wonder that you are "not able to find..." :-)
--SA
arshad alam 11-Oct-12 3:51am    
put a break point . try to debug the code. if get any exception. share it with us.

The error message tells you very explicitly what you have to do to find out what the problem is.

All you have to do is follow the instructions given (which are in plain English, with an example) and the error will be displayed in all it's glory.
Until then, nothing you or we can do will help to fix the problem.
 
Share this answer
 
Comments
Member 7925220 11-Oct-12 4:00am    
Actually I doesn't want to redirect on custom page I just need data on my page that is label control.
OriginalGriff 11-Oct-12 4:20am    
You won't get either until you find out what the error it is trying to report is.
At the moment, you have a message saying "Your code doesn't work. I know why, but I'm not allowed to tell you. This is how you let me tell you what the exception is, and what line is causing it".
Follow the instructions, and it will give you actual information...
I solve it myself actually I forget to open connection, so I get this error thank you.
 
Share this answer
 
Comments
damodara naidu betha 11-Oct-12 5:16am    
Good :)
Open your Web.config file
and in <system.web></system.web> define like following
<system.web><br />
        <customerrors mode="Off" /><br />
</system.web>


Thanks
 
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