Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have the following issue. Quick help required..

1) I have a web application to be hosted on IIS. When I run the application in the debug mode locally the application connects to the Database and it all works fine. But when I try to host it on IIS server and then try to access the application it is hosted but not connecting to the Data Base. I tried to find out the root cause and found that the CreateDatabase(string DatabaseConnectionString) is throwing an exception in the repository of the Dataaccess block.

Here is the exception message.

"The value can not be null or string or empty.\r\nParameter name: id"

Following is the stack trace :

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](String id, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.Create(String name)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String name)
at DERAS.Common.DataAccess.Repository`1..ctor(String databaseName) in D:\DERAS.Common\DataAccess\Repository.cs:line 29



Please provide a solution for this problem as I need to host my application and make it connect to the the DB as soon as possible



Thank You.

Farhan
Posted

The message is clear. When calling BuildUp[T] method, the parameter string id that you are passing to it is null or empty. Make sure that you are not passing the null or empty string as parameter.

Cheers
 
Share this answer
 
Comments
Farhanishaqui 10-Sep-11 2:31am    
Hi Mario,

While calling the Repository CreateDatabase() method, the connection string is picked up from the web config file. The BuildUp[T] method is out of scope to program if you are using Enterprise Libraries.

So, Already the connection string value is coming from web config, which is correct but the question is why it is not picked up correctly when the application is running from IIS.
The account that is used by IIS application pool may not have the required permissions to connect to the SQL Server database. Verify the settings in the Method 3 section using this link: http://support.microsoft.com/kb/823287[^]

Hope it helps to solve the issue...
 
Share this answer
 
Hello Dears,



I revisited all the ROLES AND permissions for Network service and gave appropriate permissions (eg: dbOwner) and this gave me the answer to all my questions. I was able to connect to the database and run my application correctly :)



Thanks All for your answers...



Regards,

Farhan
 
Share this answer
 
Hello Guys,

Can any one help me with this.. I am still stuck. Not able to host my app on IIS :(
 
Share this answer
 
I fixed it on my machine. But when hosted on IIS on windows sever 2008 not able to connect to data base which is present on the same server.

Login Failed for user exception :(

What to do now?

Please help.


Regards,
Farhan
 
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