Our recent ASP.NET project has began to grow bigger and bigger, so yesterday I decided to grab all business logic from the project, separate to components and put them into class libraries. Mostly I used some automated copying process, but in ‘ClientManagerClassLibrary’ I had to recreate my ‘ClientProfile’ LINQ to SQL class using the built-in wizard in Visual Studio 2008 SP1 (…sure you know the process: Add new item -> LINQ to SQL class -> dropping the table and stored procedures into designer -> Save). After separating, the project still worked fine on my developer machine, not like on my server. I got this error:
SQL Server 2005 Error: “A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) ”
I could not imagine what the hell is wrong with SQL Server. My connection string and SQL configuration the same on both machine and I didn’t modify that. So what else?
The solution have found in LINQ codebehinds.
<asp:ListView ID="livComments" runat="server" DataSourceID="CommentsObjectDataSource" EnableViewState="False" onitemcommand="livComments_ItemCommand" >
<ItemTemplate>
... /template here/ ...
</ItemTemplate>
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
<asp:DataPager ID="CommentDataPager" runat="server" PageSize="5">
<Fields>
<asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
<PagerTemplate>
<asp:Button ID="FirstButton" runat="server" CssClass="first" CommandName="First" Text="First" Enabled='<%# Container.StartRowIndex > 0 %>' />
<asp:Button ID="PreviousButton" runat="server" CommandName="Previous" Text='<%# (Container.StartRowIndex - Container.PageSize + 1).ToString() + " - " + (Container.StartRowIndex).ToString() %>' Visible='<%# Container.StartRowIndex > 0 %>' />
<!--<asp:Label ID="CurrentPageLabel" runat="server" Text='<%# (Container.StartRowIndex + 1).ToString() + "-" + ((Container.StartRowIndex + Container.PageSize > Container.TotalRowCount) ? (Container.TotalRowCount) : (Container.StartRowIndex + Container.PageSize)).ToString() %>' />-->
<asp:Button ID="NextButton" runat="server" CommandName="Next" Text='<%# (Container.StartRowIndex + Container.PageSize + 1).ToString() + " - " + ((Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount) ? (Container.TotalRowCount) : (Container.StartRowIndex + Container.PageSize*2)).ToString() %>' Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
<asp:Button ID="LastButton" runat="server" CssClass="last" CommandName="Last" Text='Last' Enabled='<%# Container.StartRowIndex < (Container.TotalRowCount - Container.PageSize) %>'/>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</LayoutTemplate>
</asp:ListView>
You’ll get something like this:

Last night I wanted to share our currently developed CMS (ASP.NET 2.0 project), so I copied the working application from my developer machine to a home server running on Windows 7, IIS 6.1. After I configured the connection string, I got the following error:
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
It’s not a simple “Login failed” message, adding rights to the database didn’t solve the problem. The solution was changing the Application Pool of the website deep inside the IIS Manager:
In IIS, choose the website that tries to connect to the database, and click on “Advanced Settings”. 
Take a look at the Application Pool used, in this case DefaultAppPool.
Now go to the Application Pools in IIS root, right click the DefaultApplicationPool and choose Advanced Settings. Find the Identity field and choose LocalService as the Built-in account.
Now try again with your website.