Tuesday, February 28, 2006

Configuring ASP.NET 2.0 Application Services to use SQL Server 2000

I was just trying out the code in Introducing ASP.NET Web Part Connections and I immediately stumbled upon an error stating "System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server." Fortunately I got to this great blogposting from Scott Guttrie - important things to know:
  • Most of the ASP.NET 2.0 application services are configured to use the built-in SQL Express provider. Since I didn't install it ;-(

  • If you want to use a different provider - you first need to create the SQL database scheam with the aspnet_regsql.exe utility

  • Point your web application to the new DB in your web.config - just replace the connectionstring value for the "LocalSqlServer in the web apps web.config
    <remove name=”LocalSqlServer”/>
    <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=appservicesdb;Integrated Security=True" providerName="System.Data.SqlClient"/>

  • No comments: