Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Database connection problem

Database connection problem

Scheduled Pinned Locked Moved C#
helpdatabasedesignsysadmindata-structures
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wsamuel
    wrote on last edited by
    #1

    Server Error in '/MemberPhoto' Application. -------------------------------------------------------------------------------- Value cannot be null. Parameter name: String Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: String Source Error: Line 23: dbConnectionString = ConfigurationManager.ConnectionStrings["MemberPhotoConnection"].ConnectionString; Line 24: dbProviderName = ConfigurationManager.ConnectionStrings["MemberPhotoConnection"].ProviderName; Line 25: productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]); Line 26: productDescriptionLength = Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]); Line 27: siteName = ConfigurationManager.AppSettings["SiteName"]; Source File: c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs Line: 25 Stack Trace: [ArgumentNullException: Value cannot be null. Parameter name: String] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2725203 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102 System.Int32.Parse(String s) +20 MemberPhotoConfiguration..cctor() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs:25 [TypeInitializationException: The type initializer for 'MemberPhotoConfiguration' threw an exception.] MemberPhotoConfiguration.get_DbProviderName() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs:45 GenericDataAccess.CreateCommand() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\GenericDataAccess.cs:111 CatalogAccess.GetDepartments() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\CatalogAccess.cs:54 DepartmentsList.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\MemberPhoto\UserControls\DepartmentsList.ascx.cs:22 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.Load

    G 1 Reply Last reply
    0
    • W wsamuel

      Server Error in '/MemberPhoto' Application. -------------------------------------------------------------------------------- Value cannot be null. Parameter name: String Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: String Source Error: Line 23: dbConnectionString = ConfigurationManager.ConnectionStrings["MemberPhotoConnection"].ConnectionString; Line 24: dbProviderName = ConfigurationManager.ConnectionStrings["MemberPhotoConnection"].ProviderName; Line 25: productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]); Line 26: productDescriptionLength = Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"]); Line 27: siteName = ConfigurationManager.AppSettings["SiteName"]; Source File: c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs Line: 25 Stack Trace: [ArgumentNullException: Value cannot be null. Parameter name: String] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2725203 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102 System.Int32.Parse(String s) +20 MemberPhotoConfiguration..cctor() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs:25 [TypeInitializationException: The type initializer for 'MemberPhotoConfiguration' threw an exception.] MemberPhotoConfiguration.get_DbProviderName() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\MemberPhotoConfiguration.cs:45 GenericDataAccess.CreateCommand() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\GenericDataAccess.cs:111 CatalogAccess.GetDepartments() in c:\Inetpub\wwwroot\MemberPhoto\App_Code\CatalogAccess.cs:54 DepartmentsList.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\MemberPhoto\UserControls\DepartmentsList.ascx.cs:22 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Control.Load

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      wsamuel, "ProductsPerPage" is obviously null.

      Line 25: productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);

      Its got nothing to do with the database. I am sure you posted something VERY similar a week or so go, but was for different line, but the same error... Regards, Gareth.

      W 1 Reply Last reply
      0
      • G Gareth H

        wsamuel, "ProductsPerPage" is obviously null.

        Line 25: productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);

        Its got nothing to do with the database. I am sure you posted something VERY similar a week or so go, but was for different line, but the same error... Regards, Gareth.

        W Offline
        W Offline
        wsamuel
        wrote on last edited by
        #3

        Server Error in '/MemberPhoto' Application. -------------------------------------------------------------------------------- An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I've got another error for my program. This is obvious because of the connection problem. May i know more precisely what is going on?

        G N 2 Replies Last reply
        0
        • W wsamuel

          Server Error in '/MemberPhoto' Application. -------------------------------------------------------------------------------- An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I've got another error for my program. This is obvious because of the connection problem. May i know more precisely what is going on?

          G Offline
          G Offline
          Gareth H
          wrote on last edited by
          #4

          wsamuel, Well, firstly you should check:

          When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

          And also your connection string. Regards, Gareth.

          W 1 Reply Last reply
          0
          • W wsamuel

            Server Error in '/MemberPhoto' Application. -------------------------------------------------------------------------------- An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I've got another error for my program. This is obvious because of the connection problem. May i know more precisely what is going on?

            N Offline
            N Offline
            nelo_
            wrote on last edited by
            #5

            Gareth is right. The error message gives you a clue. By default a SQL Server 2005 database only allows connections that originate from applications running on the same database server. You need to the change the Remote Connections settings in the SQL Server 2005 Surface Area Configuration. You'll see that the default is local connections only. You need to change to local and remote connections and pick one of the sub-options. Can we have a look at the connection string?

            W 1 Reply Last reply
            0
            • G Gareth H

              wsamuel, Well, firstly you should check:

              When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

              And also your connection string. Regards, Gareth.

              W Offline
              W Offline
              wsamuel
              wrote on last edited by
              #6

              Should i instead check on my coding or check on the connection setup? Is there any tutorial or sample showing how to configure the connection?

              1 Reply Last reply
              0
              • N nelo_

                Gareth is right. The error message gives you a clue. By default a SQL Server 2005 database only allows connections that originate from applications running on the same database server. You need to the change the Remote Connections settings in the SQL Server 2005 Surface Area Configuration. You'll see that the default is local connections only. You need to change to local and remote connections and pick one of the sub-options. Can we have a look at the connection string?

                W Offline
                W Offline
                wsamuel
                wrote on last edited by
                #7

                ya sure.. // creates and prepares a new DbCommand object on a new connection public static DbCommand CreateCommand() { // Obtain the database provider name string dataProviderName = MemberPhotoConfiguration.DbProviderName; // Obtain the database connection string string connectionString = MemberPhotoConfiguration.DbConnectionString; // Create a new data provider factory DbProviderFactory factory = DbProviderFactories.GetFactory(dataProviderName); // Obtain a database specific connection object DbConnection conn = factory.CreateConnection(); // Set the connection string conn.ConnectionString = connectionString; // Create a database specific command object DbCommand comm = conn.CreateCommand(); // Set the command type to stored procedure comm.CommandType = CommandType.StoredProcedure; // Return the initialized command object return comm; } Does this means it's the problem with the configuration? I have try the method you recommended by changing the setting but it still didn't work. Is there any other solution for this? Thx!

                modified on Sunday, March 30, 2008 10:16 AM

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups