Click here to Skip to main content
15,503,887 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my application i am working with a web application after testing for several times in my local system i hosted it in webserver unfortunately i am getting "the page cannot be displayed because an internal server error has occurred" where as it is working fine in my local server.. only that page their is using database(sql server 2000

My code :- error on that page whenever i click on submit button "The page cannot be displayed because an internal server error has occurred." this error occured.
VB.NET
Imports System.Data.SqlClient
Imports System.Data
Imports System.Configuration
Imports System.Collections
Partial Class feedback
    Inherits System.Web.UI.Page
    Dim cmd As New SqlCommand
    Dim da As New SqlDataAdapter
    Dim ds As New DataSet
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con1 As String
        
        con1 = ConfigurationManager.AppSettings("Con1").ToString()
        Dim con As New SqlConnection(con1)
        con.Open()
        Dim cmd As New SqlCommand
        
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "insert_feedback"
        cmd.Parameters.AddWithValue("@First_Name", TextBox1.Text)
        cmd.Parameters.AddWithValue("@Contact_Number", TextBox2.Text)
        cmd.Parameters.AddWithValue("@Email_Id", TextBox3.Text)
        cmd.Parameters.AddWithValue("@Comment", TextBox4.Text)
        cmd.Connection = con
        
        cmd.ExecuteNonQuery()
        ClientScript.RegisterStartupScript(Me.GetType(), "Option Alert", "<script>alert('Feedback Saved Successfully!.')</script>")
        con.Close()
    End Sub
    
End Class

[Edit:Added pre tags]


This is my web configuration form i think connection problem in web confiu file so plz help...............my connection string is right or wrong.

XML
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>



    <appSettings>
    <add key="Con1" value="Data Source=server;uid=snehalata_SQLLogin_1;pwd=cgfn2lo3p3;initial catalog=Testobject"/>
  </appSettings >
    <connectionStrings>

        <add name="con1" connectionString="workstation id=Testobject.mssql.somee.com;packet size=4096;user id=snehalata_SQLLogin_1;pwd=cgfn2lo3p3;data source=Testobject.mssql.somee.com;persist security info=False;initial catalog=Testobject"/>
    </connectionStrings>

    <system.web >
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->
        <compilation debug="true" strict="false" explicit="true">
            <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>
        <pages>
            <namespaces>
                <clear/>
                <add namespace="System"/>
                <add namespace="System.Collections"/>
                <add namespace="System.Collections.Generic"/>
                <add namespace="System.Collections.Specialized"/>
                <add namespace="System.Configuration"/>
                <add namespace="System.Text"/>
                <add namespace="System.Text.RegularExpressions"/>
                <add namespace="System.Linq"/>
                <add namespace="System.Xml.Linq"/>
                <add namespace="System.Web"/>
                <add namespace="System.Web.Caching"/>
                <add namespace="System.Web.SessionState"/>
                <add namespace="System.Web.Security"/>
                <add namespace="System.Web.Profile"/>
                <add namespace="System.Web.UI"/>
                <add namespace="System.Web.UI.WebControls"/>
                <add namespace="System.Web.UI.WebControls.WebParts"/>
                <add namespace="System.Web.UI.HtmlControls"/>
            </namespaces>
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
        </pages>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
 -->
     <customErrors mode="off" defaultRedirect="">

            <error redirect="/default.aspx" statusCode="404" />
        </customErrors>





    <httpHandlers>
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>


    </httpHandlers>
        <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        </httpModules>

  </system.web>
    <system.codedom>
        <compilers>
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
            <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="OptionInfer" value="true"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
        </compilers>
    </system.codedom>
    <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
            <remove name="ScriptModule"/>
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <remove name="ScriptHandlerFactory"/>
            <remove name="ScriptHandlerFactoryAppServices"/>
            <remove name="ScriptResource"/>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </handlers>
    <httpErrors>
      <error statusCode="404" path="/default.aspx" responseMode="ExecuteURL" />

    </httpErrors>

  </system.webServer>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

</configuration>
Posted
Updated 22-Oct-12 22:00pm
v7
Comments
Sergey Alexandrovich Kryukov 22-Oct-12 0:40am    
Not enough information.
--SA
patilsneh 22-Oct-12 2:17am    
what information i will give to u then u solve that problem.....plz tell me.........i'm new in programming.
bbirajdar 22-Oct-12 1:20am    
You need to test the application on sql 2000 before deploying....This is only the first error ..A lot more are waiting for you
patilsneh 22-Oct-12 2:19am    
i don't understand what u saying........plz tell me in detail
bbirajdar 22-Oct-12 2:39am    
You should install sql server 2000 locally and test the application on it... Only then you should move for deployment

1 solution

I don't think "MsgBox" method should be used in an ASP.NET app since it runs on server and then renders the HTML on the client side. SO if you expect to see a message box on the client side using MsgBox(), you can forget it this exact error would stop you.

Try removing the MsgBox function and then re-run it (assuming everything else is ok, it should work) if it doesn't then you should set the customErrors to "off" in your web.config and see what exactly the error is.

EDIT: Also remove the following from your code:

VB
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet


You won't be able to preserve the state of these objects between postbacks, so I would suggest moving them to where they are actually being used. And another point, don't write data access code in your GUI, it should be separated out to a different class library and called via another intermediate layer called business layer. Try googling for n-tier architecture in .NET apps.
 
Share this answer
 
v2
Comments
patilsneh 23-Oct-12 1:24am    
Thanx aman
i follow ur suggesion bt same error r occured ..................
patilsneh 5-Nov-12 23:02pm    
I have solved my problem..........thanx to all of you..........

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