Friday, March 9, 2012

I am not able to connect to SqlServer 2005

Hi All,

I am trying to connect to SqlServer 2005 whihc is running on another machine. But it is giving error. ie.

"

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

"

this si my connection string information

//SqlConnection cn = new SqlConnection("Server=id03;uid=sa;pwd=infokall;database=TestDB");

SqlConnection cn = new SqlConnection(conn);

SqlCommand cmd = new SqlCommand();

string Value;

string query = sqlInfo.SQL;

cmd.CommandType = CommandType.Text;

cmd.Connection = cn;

cmd.CommandText = query;

if (Convert.ToInt32(cn.State) == 0)

cn.Open();

Value = cmd.ExecuteNonQuery().ToString();

// return Value;

Response.Write(Value);

plz help me out.

Regards

Raju

Have a look at the Screencast "Enable Remote Connections" on my site under the section Screencast > Enable Remote Connections

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||

(Great screencast Jens)

Raju,

Another things to keep in mind that this error may also be the result of a firewall blocking traffic. Please see the BOL for instructions on configuring the Windows firewall (http://msdn2.microsoft.com/en-us/library/ms175043.aspx).

Il-Sung.

No comments:

Post a Comment