making a connection string to localDB

  • Thread starter Thread starter Gidmaestro
  • Start date Start date
G

Gidmaestro

Guest
I have a VB.net application that interacts with a SQL Server database on my local PC. I want to distribute it, so I tried to get it to work with LocalDB.

In my app.config file I put the following, but the connection times out.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="MyConnectionString"
connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=EchoDatabase;Integrated Security=SSPI;AttachDBFilename=App_Data\EchoDatabase.mdf"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>

My visual studio project looks like this:

1452502.png

I find that when I run the program, it does return a correct connectionstring (at least the path is correct because Visual Studio copies the database over to the executable folder):

Server=.\SQLExpress;AttachDbFilename=C:\gideonwroteprograms\EchoTheory\EchoTheory\bin\Debug\App_Data\EchoDatabase.mdf;Database=EchoDatabase;Trusted_Connection=Yes;


but I get a message that sqlExpress has to allow remote connections, even though SQLExpress is on my local PC.

Thanks.

Continue reading...
 
Back
Top