Answered by:
Connect to sql via ip adress.

Question
-
I have two computers in local network the first is the server with ip 192.168.1.10 the second is the client 192.168.1.12
How can i connect client to server via ip adress>?And also client to read sqldatabase from server. I have create a connection named sillogos.mdf and i used windows authentication
I found this: Data Source=192.168.1.10;Network Library=DBMSSOCN; Initial Catalog=sillogos;User ID=?;Password=?;
Also Which is username and password( i used windowsauthentication)
I take massage login failed user'sa'
My server have this connection string Data Source=.\SQLEXPRESS;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
Thursday, February 18, 2016 2:27 PM
Answers
-
- Proposed as answer by Ice Fan Friday, February 19, 2016 3:04 AM
- Marked as answer by Lydia ZhangMicrosoft contingent staff Tuesday, March 8, 2016 2:08 AM
Thursday, February 18, 2016 8:19 PM -
- Marked as answer by Lydia ZhangMicrosoft contingent staff Tuesday, March 8, 2016 2:08 AM
Friday, February 19, 2016 7:53 AM
All replies
-
Hello,
Sure you can use the IP address to connect to a SQL Server, but if it's a named instance then you have to add the instance Name or the used IP port. To logon using Windows Authentication you have to use the Integrated Security, as in your connection string. Example with IP address and instance name
Source=192.168.1.12\SQLEXPRESS;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
and with IP port, here 1433 as example:
Source=192.168.1.12, 1433;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
Olaf Helper
[ Blog] [ Xing] [ MVP]Thursday, February 18, 2016 2:38 PM -
Thank you for reply. I use this
SqlConnection con = new SqlConnection(@"Data Source=Source=192.168.1.11\SQLEXPRESS;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("insert into customermaster(name) values ('" + textBox1.Text + "')",con);
cmd.ExecuteNonQuery();con.close();
and i have this message
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Thursday, February 18, 2016 2:59 PM -
-
No i cant connect i use
192.168.1.11\SQLEXPRESS
With windows authentication
Thursday, February 18, 2016 3:31 PM -
Sure the SQL Server is running?
By Default remote Connections are disables for Express Edition => How to enable remote connections in SQL Server 2008?
Is IP network protocol enabled? => How to: Enable the TCP/IP Protocol for a Database InstanceSee also: How to Troubleshoot Connecting to the SQL Server Database Engine
Olaf Helper
[ Blog] [ Xing] [ MVP]Thursday, February 18, 2016 3:44 PM -
I have install in two computers visual studio 2010.
In first machine i add a connection "Microsoft SQL Server Database File (SqlClient)" and database filename 'sillogos.mdf'
In second computer i want to connect to sillogos.mdf
and to run this code
SqlConnection con = new SqlConnection(@"Data Source=Source=192.168.1.11\SQLEXPRESS;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("insert into customermaster(name) values ('" + textBox1.Text + "')",con);
cmd.ExecuteNonQuery();
- Edited by Dimis1989-chris Thursday, February 18, 2016 4:06 PM
Thursday, February 18, 2016 3:53 PM -
Data Source=Source=192.168.1.11\SQLEXPRESS;AttachDbFilename=C:\backup\sillogos.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
AFAIK starting a user instance on a remote machine is not possible, they work only local. You have to attach your database as a permanent database to SQL Server to access it from remote machines: Attach a DatabaseOlaf Helper
[ Blog] [ Xing] [ MVP]Thursday, February 18, 2016 5:26 PM -
Sir it doesnt work . I have attached my database as you said. If i will try to connect with SSMS what will i write to server name?
192.168.1.11\SQLEXPRESS?
with windows authentication?
Thursday, February 18, 2016 7:54 PM -
- Proposed as answer by Ice Fan Friday, February 19, 2016 3:04 AM
- Marked as answer by Lydia ZhangMicrosoft contingent staff Tuesday, March 8, 2016 2:08 AM
Thursday, February 18, 2016 8:19 PM -
- Marked as answer by Lydia ZhangMicrosoft contingent staff Tuesday, March 8, 2016 2:08 AM
Friday, February 19, 2016 7:53 AM