Hi pkarthik,
From your description, I understand that after creating virtual directory for the existing web project, the web site failed to connect to the SQL Server 2005. However, debug the project in Visual Studio works well. If I have misunderstood your concern, please let me know.
Based on my experience, the most likely cause of this issue is the login account. When view the page through IIS, the build-in account: ?ASPNET? account (for IIS 5) or ?Network Service? account (for IIS 6) will fail to connect the SQL Server.
To fix this issue, you can choose one of the solutions:
1. Change the Authentication Mode to SQL mode in connection string, for example:
Data Source=ServerAddress;Initial Catalog=database;Integrated Security=True
Data Source= ServerAddress;Initial Catalog=database;User ID=***;Password=*****
2. Use ASP.NET impersonation.
ASP.NET Impersonation
http://msdn2.microsoft.com/en-us/library/xh507fc5(vs.80).aspx
3. Add build-in ASP.NET account in SQL Server logins.
In SQL Sever Management Studio, expand ?Security? node, right click ?Logins? node and select ?New Login??. Add ?machineName\ASPNET? or ?machineName\Network Service?
Sincerely,
Benson Yu
Microsoft Online Community Support
Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.