How to connect to SQL Server from another computer?
If you want to connect to SQL server remotly you need to use a software - like Sql Server Management studio.
The computers doesn't need to be on the same network - but they must be able to connect each other using a communication protocol like tcp/ip, and the server must be set up to support incoming connection of the type you choose.
if you want to connect to another computer (to browse files ?) you use other tools, and not sql server (you can map a drive and access it through there ect...)
To Enable SQL connection using tcp/ip read this article:
For Sql Express: express
For Sql 2008: 2008
Make sure you enable access through the machine firewall as well.
You might need to install either SSMS or Toad on the machine your using to connect to the server. both you can download from their's company web site.
Connect to SQL Server from another computer - SQL network-instance related issue (with error 258)
This tuto solved the problem for me:
Allow SQL Server through Windows Firewall (
https://www.youtube.com/watch?v=3jVTUll4PXs)
I had to add the paths of the sql server and sql server browser services to the allowed apps by the firewall.
Connecting to SQL server from another computer
There are few things you should check:
Remove "Trusted_Connection=True;" in your connection string
Turn off the firewall on both machines for testing. If it works, you can enable the both of them and then configure the access rights for specific application
Enable SQL Authentication on SQL Server instance: http://kbase.gfi.com/showarticle.asp?id=KBID002804
Simple way to test it works or not without running your c# code: you can install the SQL Management Studio on the code-machine and try to connect the SQL Server instance.
Hope it helps.
C# SQL database access from another PC
The issue is resolved! All the steps I followed are perfect. You can say that if you want to connect to the client's PC using an ethernet connection. Follow the steps in question step by step. Focus on the connection string. Use the connection string of number 3. Let me write it again for clarification.
Data Source=tcp:DESKTOP-0DCQGE3,49172;Initial Catalog=dbposrpc;User ID=sa;Password=12345678;
Here SQLEXPRESS
is the SQL Server instance name, DESKTOP-0DCQGE3
is the server PC name, 49172
is the TCP port that I selected as static.
How I resolved the issue?
I just cleared the solution, restarted the project again and everything worked fine for me.
How to connect SQL Server Express database from another Pc?
On PC1
, you must ensure that the SQL Server Express instance allows remote connections (see this other SO question and its answers for details on how to do this.
Also, you need to create logins on the server instance, and users in your database(s). If all those three PC's are members in a Windows network, you can probably create logins based on Windows user accounts - otherwise, you have to use SQL Server specific logins.
Then, on PC2 and PC3, you can use something like this:
server=PC1;database=YourDatabase;User ID=SomeUserID;Password=SomePassword
See ConnectionStirngs.com for a great many more examples and explanations
Update:
If I understand correctly, this is what you want to do:
have
PC1
be the "server" in your setup - if so, then install SQL Server Express with tools (including the Management Studio) on this server. Make a note of what instance name you use when installing SQL Server Express! The default isSQLEXPRESS
, but you can choose anything you likemake sure the SQL Server Express instance allows remote connections
create the necessary logins on that server instance
create your database on that server (where it belongs - after all, SQL Server is a server-based solution)
create the necessary users in that database for your logins
With this setup, you should easily be able to connect from PC2
and PC3
to your SQL Server database on PC1
Related Topics
Why Does This SQL Code Give Error 1066 (Not Unique Table/Alias: 'User')
Return a Value If No Record Is Found
Is There Common Street Addresses Database Design for All Addresses of the World
Return Pre-Update Column Values Using SQL Only
SQL Server Deterministic User-Defined Function
How to Use SQL Order by Statement to Sort Results Case Insensitive
Sql: Select Dynamic Column Name Based on Variable
How to Query for All Dates Greater Than a Certain Date in SQL Server
SQL Recursive Query on Self Referencing Table (Oracle)
SQL Pivot and String Concatenation Aggregate
Does Sparksql Support Subquery
Get the Last Day of the Month in SQL
How to Set Auto Increment Primary Key in Postgresql
How to Sort a Varchar Column in SQL Server That Contains Numbers
Db Design to Use Sub-Type or Not
How to Insert Values into a Table, Using a Subquery with More Than One Result
Easiest Way to Populate a Temp Table with Dates Between and Including 2 Date Parameters