[source]using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace Database
{
class Database_Main
{
SqlConnectionString ConnStr = new SqlConnectionString();
public Database_Main()
{
SqlConnection Connection = new SqlConnection(@."user id=Afr0;password=prins;server=(local);Trusted_Connection=yes;database=Nimdalin;");
Connection.Open();
}
}
}
[/source]
The message I get says that:
"An error has occured while establishing a connection to the server."
What could be the possible reasons for this? Is there any way to configure my server to accept remote connections amongst other things? All the times I've seen people mentioning this they say that you can turn this on in the SQL Server Configuration Manager, but I can't find out where in the program that option is! Also, how do I check which users are available to my database? I've added a user + pass by using SQL code, but I'd like to make sure that it's there just in case.
I usually find out how to write the query string from http://www.connectionstrings.com/
Your connectionstring has some contradictive parts in it. If you want to use a user/password you should probably use this instead
"Server=localhost;Database=Nimdalin;User ID=Afr0;Password=prins;Trusted_Connection=False"
To enable remote connection you can use the surface area configuration tool
I can start it from the Start menu: Start->All Programs->Microsoft SQL Server 2005->Configuration Tools->SQL Server Surface Area Configuration
There you have options to enable remote connection among others.
|||Hi Afr0,
SQL Server Express comes with all the remote protocols disabled by default. In addition to the SAC, you can also use the SQL Server Configuration Manager (Start -> All Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Configuration Manager). Just expand SQL Server 2005 Network Configuration and select the SQL Express instance and you'll see the list of supported protocols. Also, make sure that your SQL Browser is enabled and your firewall isn't blocking the connections. (See the following KB articles about enabling a firewall, http://support.microsoft.com/kb/287932/en-us, http://support.microsoft.com/kb/841249/en-us).
In addtion, Ming posted a great help guide in the SQL Protocols blog:
http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx
Let me know how it goes.
Il-Sung.
No comments:
Post a Comment