Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 10th, 2010, 10:59 PM   #1
12179
Newbie
 
Join Date: Jul 2009
Posts: 11
Rep Power: 0 12179 is on a distinguished road
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
12179 is offline   Reply With Quote
Old Jan 11th, 2010, 9:28 PM   #2
12179
Newbie
 
Join Date: Jul 2009
Posts: 11
Rep Power: 0 12179 is on a distinguished road
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=myPassword

and 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?
12179 is offline   Reply With Quote
Old Jan 14th, 2010, 5:35 PM   #3
12179
Newbie
 
Join Date: Jul 2009
Posts: 11
Rep Power: 0 12179 is on a distinguished road
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
12179 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using SQL Server Compact Edition rostamiani C# 3 Dec 1st, 2008 5:58 AM
How to return SQL Query info to a form? AFProgMan ASP.NET 5 Oct 29th, 2008 11:16 AM
Linking remote server and machine program rajasalleh C++ 9 Sep 29th, 2008 5:12 PM
Help with sql connection ghg5 C# 1 May 19th, 2008 3:00 PM
Detach an in-use database via code (SQL Server 2000) sma_soft C# 1 Aug 14th, 2007 3:22 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC