Click here to Skip to main content
13,193,650 members (60,307 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi all,

I need to connect my Visual Studio LightSwitch with VB.NET project to SQL database which is located on a shared drive on a local network ..

Database Name is: Proj2014DB.mdf
The PC name containing the DB is: PCNO10
Drive on PCNO10 containing the DB is drive: D:\MyDatabase\

When trying to publish my project to be shared for working over the network Visual Studio LightSwitch asks me to provide the SQL user connection string to the database to be able to connect to the database after publishing.

The required connection string is in the format:

Data Source=PCNO01-PC;Initial Catalog="Proj2014";Integrated Security=True;Pooling=True;Connect Timeout=30;User Instance=False

My question is what is the correct connection string to make sure all pcs on the network will connect to the database mentioned above (I think they are marked with bold text which need to be corrected).


Thanks in advance
Maher
Posted 18-Aug-14 8:03am
Updated 18-Aug-14 8:05am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Provided that the PC that the Proj2014.mdf is located on is setup to properly run SQL Server (or Express or LocalDB), include the PC Name (or IP Address)\ SQL Server name. See below:

Data Source=PCNO01-PC\SQLEXPRESS;Initial Catalog="Proj2014";Integrated Security=True;Pooling=True;Connect Timeout=30;User Instance=False
  Permalink  
Comments
ehabelnahas 18-Aug-14 15:34pm
   
Many thanks, I will try that and feed you back,

well, If that works, do you mean that I have to install SQL server in the pc having the database only? or it will be also necessary that SQL being installed in all pcs?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

It will need to be installed on the PC that has the database file. Based on the needs, there are different versions to look at:

LocalDB - on a local PC - Great for Developing and Test

SQL Express - Great for light use across the network with a few users.

SQL Server - High-End use
  Permalink  
Comments
ehabelnahas 31-Aug-14 15:54pm
   
I'm afraid I couldn't achieve that...
I have now SQL server 2012 installed and I tried many instances of connection strings without success!!
I couldn't publish the application at all using connection string referring to a pc on my network.

Data Source=EHABELNAHAS-PC\SQLEXPRESS;Initial Catalog=Application2aPP;Integrated Security=True;Pooling=True;Connect Timeout=30;User Instance=False

I need 1st to be able to publish the application :(
ehabelnahas 31-Aug-14 16:04pm
   
EHABELNAHAS-PC\SQLEXPRESS always gives an error no connection established to EHABELNAHAS-PC\SQLEXPRESS
Eldon Elledge 4-Sep-14 8:47am
   
What kind of error message are you getting?
ehabelnahas 6-Sep-14 15:12pm
   
OK, now I downloaded SQL Server 2014 and I followed the next steps:

1- I made a SQL Server Instance named: MYSQLserver

2- I Created a database called: MyDatabase attached to MYSQLserver

3- and already I attached a new LightSwitch project to that database as an external data source, and the connection string was:

"Data Source=EHABELNAHAS-PC\MYSQLserver;Initial Catalog=MyDatabase;Integrated Security=True"

4- Everything is ok, now I'm trying to publish the application, now what is the "How do you want to publish the default database?" for?? and what should I choose from the two options?


5- Second this is Visual Studio 2013 LightSwitch Publish wizard now asks me for three connection strings:
•Is the Attached Data Sources connection string
•Is the User connection string
•Is the Publish database Schema

I put the same connection string in all connection strings "PC\MYSQLserver;Initial Catalog=MyDatabase;Integrated Security=True" but it always give the error "An exception occurred when deploying the database for the application. Couldn't deploy package"

and when double click on it, it takes me to:

<



Target Name="DeploySchema"



Condition=" '$(ExecuteSchemaDeploy)' == 'true' ">

<



DeploySchema ConnectionString="$(PublishConnectionString)"

IncludeSecurityDBObjects="true"

ServerArtifactsFolder="$(_ServerArtifactsFolder)"



Collation="$(DatabaseCollation)"



IntrinsicDacPackageFilePath="$(_IntrinsicDacPackageFilePath)"



DatabaseProject="@(_DatabaseProjectItem)"



Inputs="@(ServerMetadataFiles)"

ProjectPath="$(MSBuildProjectFullPath)"/>




Please Help
Eldon Elledge 9-Sep-14 9:28am
   
It seems that you have everything in place. I do not see anything that would be an issue. Maybe some one else could see something I'm missing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.171018.2 | Last Updated 18 Aug 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100