Antonio March

Antonio March

  • NA
  • 3
  • 11.6k

Connecting to a mdf file

Sep 24 2010 3:20 PM
I downloaded an example of VB .NET program that opens a mdf file included in the same VB solution. The connectionstring is in the app.config file

I am using VB 2010 Express and SQL Server 2008 R2 (express, too, so free)

but it doesn't work for me.
the app.config is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="default"
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Chinook.mdf;Integrated Security=True;User Instance=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>


and the error I get is

Failed to generate a user instance of SQL Server due to a failure in starting  the process for the user instance. The connection will be closed

and the code is

     Dim conn As SqlConnection
     conn = New SqlConnection(ConfigurationManager.ConnectionStrings("default").ToString())


I really don't know where to look at.

thanks

Answers (1)