![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2009
Posts: 11
Rep Power: 0
![]() |
Connection string to remote server (SQL Server)
Is there a special connection string to connect to a database on a remote server (without using the IP address)?
I have a C# application and also have a username and password that will be used to connect to the remote database. This is the connection string I used, but it's not working: using System.Data.SqlClient; ... SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=myServerName; Database=myDataBaseName; User ID=myUsername; Password=myPassword"; ... In the link below there was an example that used an IP address, but is there any other way to do it? http://www.connectionstrings.com/sql-server-2005#p1 http://www.codemaker.co.uk/it/tips/a...emoteSQLServer |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jul 2009
Posts: 11
Rep Power: 0
![]() |
Re: Connection string to remote server (SQL Server)
Hmm... I changed the connection string to this:
Data Source=myServerName;
Initial Catalog=myDatabaseName;
Integrated Security=SSPI;
Connect Timeout=30;
user ID=myUsername;
password=myPasswordand it works now! ....but only when I'm logged on the remote computer (since I am also able to connect to SQL Server using Windows Authentication, I guess). However, it still doesn't work on a remote computer for other users using only SQL Authentication . I get this error: Login failed for user <user> http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx I already have a username/password set up that people can connect onto the SQL Server with, and added it to the connection string as shown above. And I'm not sure what this means: "If SQL Server is running on a remote computer and the Web server is running IIS 6.0, give the Web server's machine account login privileges on the remote computer. The machine account is referenced as DOMAIN\MACHINENAME$." What am I suppose to do here? |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jul 2009
Posts: 11
Rep Power: 0
![]() |
Re: Connection string to remote server (SQL Server)
I figured it out:
Data Source=myServerName;
Initial Catalog=myDatabaseName;
Integrated Security=false;
Connect Timeout=30;
user ID=myUsername;
password=myPassword |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using SQL Server Compact Edition | rostamiani | C# | 3 | Dec 1st, 2008 4:58 AM |
| How to return SQL Query info to a form? | AFProgMan | ASP.NET | 5 | Oct 29th, 2008 10:16 AM |
| Linking remote server and machine program | rajasalleh | C++ | 9 | Sep 29th, 2008 4:12 PM |
| Help with sql connection | ghg5 | C# | 1 | May 19th, 2008 2:00 PM |
| Detach an in-use database via code (SQL Server 2000) | sma_soft | C# | 1 | Aug 14th, 2007 2:22 PM |