Click here to Skip to main content
15,887,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have app programed by vb.net 2010 with sql server database file (mdf) I want to share this app so that when user click on Icon app work and run
my connection string is
"Data Source=.\myservername;Initial Catalog=mydatabase name;Persist Security Info=True;User ID=sa;Password=mypass"

my question is that : is this connection string work or not . in my pc this work . should i change any thing ?
Posted
Updated 2-Sep-15 4:59am
v2

1 solution

That will work on your machine if your SQL instance is called "myservername" as "." means your local machine so ".\myservername" means the SQL instance called "myservername" on this machine. It won't work on other machines as the code will look for SQL on their machine rather than yours. The datasource needs updated to have the name of your machine as seen by others, or your IP address if you have a fixed one. So

Data source=machinename\instancename

If the SQL instance isn't called "myservername" but you mean to replace myservername with the name of your machine, then that's not going to work. If your SQL has no specific instance name then just use

data source=myservername

Edit: The above assumes you are looking to keep the database on your machine and others will connect to it, if that's not the case update your question to supply more info.
 
Share this answer
 
v2
Comments
rezaeti 2-Sep-15 10:53am    
by the way i have code that write and read xml file to create dynamic connection string that replace txt.servername.text with myservername and so on
F-ES Sitecore 2-Sep-15 11:08am    
There is no need, using the fully qualified machine name will work on your machine as well.
rezaeti 2-Sep-15 11:35am    
is this connection work for any windows for example windows 8 or 7 or xp or ...?
and is this connection work for 64 bit and 32 bit ?
does it matter the type of sharing for example local or net or LAN or any thing else?
F-ES Sitecore 2-Sep-15 11:39am    
It'll work on anything, and it will work across any network as long as the server name use you can be used by the client machine. So if you're on a lan and someone else is on the same lan they will be able to resolve your name ok. If two machines are connected via the internet then local lan names won't translate so you'll need an IP address or a name that translates via DNS like sql.yourdomain.com
rezaeti 2-Sep-15 11:54am    
excuse me ths is last question :
when I install app on another pc this error display :
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
I search on internet about this error and I found this error is related to stoping sql express on another pc
I install sql express on it but sql exoress is not runing and my tring for runinig it was not successful
what i do ?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900