I am using SQL Server 2008 R2 Express and EF 6.
Here is my connection string which I place in app.config:
<connectionStrings>
<add name="StructuralSynthesisConnection"
connectionString="data source=192.168.0.103\sqlexpress;Network Library=DBMSSOCN;initial catalog=StructuralSynthesisDB;integrated security=True;pooling=False;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
It connects only to current computer (192.168.0.103) ONLY with ip I mentioned (it`s my local ip using wifi). When I try to connect from another computer or/and with my real ip it fails.
I turned off windows firewalls, checked default sql port (1433), no dynamic ports, tried connection string with port. Nothing helped. Also (of course) I checked my internet connection and work of SQL Server Express on all devices I am using. They are all in local (wifi) network, maybe it makes some difference?
Ok, you should check this https://blogs.msdn.microsoft.com/walzenbach/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008/.
I Think it has a few configuration that you did not mention and how to implement it.
A few month a ago i had the same problem and i set everything with the correct configuration and i did not get the connetion, and my problem was that my Antivirus was bloking the connetion.
I hope it help.
Related
I am new to SQL Server. I am doing the offline sync using SQL Server and sqlite DB. For that I followed the below tutorial SQL Server Installation. In this tutorial I am stuck on how to open the localhost service. When I run the service (localhost/AuroraSyncService.svc) in browser it shows empty.
For this I created the database AuroraSyncCn in my SQL Server Management Studio and created the new website in my IIS (internet information security).
MY coneection Strings:
<connectionStrings>
<add name="AuroraSyncCn" connectionString="Data Source=(local);Initial Catalog=SQLite-Sync.com;User ID=sa;Password=pass" providerName="System.Data.SqlClient" />
</connectionStrings>
here i tried connectionString="localhost/myservicefolde/aurorasyncservice.asmx;
Somebody help to solve this one.
From what I see your connection string should contain your database name (Initial Catalog=AuroraSyncCn).
If it's SQLExpress, instance name should probably be the same as the one mentioned by vasin1987 (server/serverinstance).
But from what I remember from ASP.NET, 'localhost' as Data Source should also be just fine.
Can you please show/write what you have in login window in MS SQL (Server name is what interest us the most):
I have problem to connect my application (on computer A) to another computer (computer B) that had the database (.mdf file).
This is my code
<connectionStrings>
<add name="HS_App.My.MySettings.DatabaseHSConnectionString"
connectionString="Data Source=Computer-B\SQLEXPRESS;AttachDbFilename=Computer-B\Users\Computer-B\Desktop\HS App\DBHS\DatabaseHS.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Computer A and B are connected via adhoc, and have the same environment ip address. Can I do that? Thanks in advance.
If you want to use a local SQL Server Express instance using AttachDbFileName for a database located on another computer it will not work: SQL Server requires local filesystem access because it does some interesting under-the-hood filesystem stuff with the database files (.mdf and the log files), so MDF files located on a network share (UNC path) or Internet location will not work, see here: http://msdn.microsoft.com/en-us/library/ms254500(v=vs.80).aspx
System.Data.SqlClient resolves the substitution strings into full paths against the local computer file system. Therefore, remote server, HTTP, and UNC path names are not supported. An exception is thrown when the connection is opened if the server is not located on the local computer.
If you want to connect to an already-running SQL Server Express instance on another computer over TCP, then you need to set-up TCP connections on that server first. Note that you cannot use AttachDbFilename either because that option only applies to "user instances" of SQL Server Express.
I have completed my program in MVC in VS 2010. In the connection string I have the following
<add name="RacePaceDBContext"
connectionString="data source=XX.XXX.XX.XXX,1433;Initial Catalog=RacePaceDataNew;Persist Security Info=True;User ID=user;Password=password;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient"/>
Which connects to a SQL Server running on an EC2 instance on Amazon AWS.
The program runs fine and the connection works great. The program connects and creates/reads data etc.
However, I am not sure why when I try "Connect To Database" in the server explorer on the left, and fill in the same settings it just doesn't connect. Any ideas why this would be different? As want to be able to log in and see my tables, data etc without having to log onto AWS. The same is true when I use MySQL Workbench to try connect - it gives me an error telling me the server isn't accessible.
it might firewall issue, Please make sure your client can connect to xx.xxx.xx.xxxx:1433.
You can also refer this : https://forums.aws.amazon.com/thread.jspa?messageID=435146
Hope this helpful.
I am currently creating a data drivien wpf application, and everything works perfectly as a charm on my development computer (the computer I used to create the program). Also, when I move the app from the Release directory and copy to my local machine, it works perfectly. But on the other hand, when my application reaches other users, it stops connecting to databases completely.
I don't get how this is as I have my connection string set properly, which is:
<connectionStrings>
<add name="MyConnectionStrint"
connectionString="Data Source=MyServerIP\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Which is an XML Config file located in the root directory. As soon as the program is given to someone else, it stops functioning completely; no data is received or sent.
Could this be because of something like, they need MS SQL Server or something for it to connect to my remote database? I even tried connecting to the database using SQL Server Management Studio, which fails to work on other PCS, but for some reason works on mine and no one else's. This is a problem as this program is meant to be distributed to at least 15 people. Any Ideas as to what Is causing this?
Any help would be appreciated, thanks.
Is the database server on your development machine ?
If so, then you have to enable the tcp/ip configuration in your SQL Server Configuration Manager.
If that's not enabled then your server will not be accessible outside of the machine on which it resides.
I have finished a program using sql server and visual studio using c# language .
I want to put the database on pc and the program that connected to that database on other PCs
I'm using this connection string in App.config :
<connectionStrings>
<add name="MWEConnectionString" connectionString ="integrated security=yes;initial catalog=MWDB;data source=.\sqlexpress"/>
</connectionStrings>
Should I change server name by pc external ip address?
and according to sql server Should I use windows authentication or what?
I don't know how to do it.
You should access the server by it's address by using Sql Server authentication.
Your connection string should look something like this:
connectionString="Data Source=192.168.0.5\SQL2008R2;Initial Catalog=MWDB;Persist Security Info=True;User ID=user;Password=password"
(this is just an example, your settings will probably be different).
Another example:
connectionString="Data Source=NAMEOFCOMPUTER\SQL2008R2;Initial Catalog=MWDB;Persist Security Info=True;User ID=user;Password=password"
for accessing the server by name.
You can generate a connection string for your application from Visual Studio. From Database Explorer -> Connect to Database
see:
http://connectionstrings.com/sql-server-2005
http://connectionstrings.com/sql-server-2005#p1