Database connection problem
-
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
-
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
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.
-
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.
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?
-
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?
-
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?
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?
-
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.
-
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?
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