2 Replies - 937 Views - Last Post: 28 January 2012 - 10:48 PM Rate Topic: -----

Topic Sponsor:

#1 nurza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-January 12

could not open a connection to SQL server

Posted 21 January 2012 - 07:51 PM

hye there ,
i'm using visual studio 2010 with the languange c# / asp.net
i've make connection to localhost database
so there is my connection string

SqlConnection con = new SqlConnection("Server=localhost;Database=estrategik;User Id=rrrr;Password=rrrr1");


my problem is when i debug the system this error will occur

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

i've try serach on google how to fix this error and i've tried follow the all step from this link
My link

but it still error , i hope u can help me to solve this problem

thanks ,
zah .

Is This A Good Question/Topic? 0
  • +

Replies To: could not open a connection to SQL server

#2 Yo!  Icon User is offline

  • D.I.C Head


Reputation: 4
  • View blog
  • Posts: 81
  • Joined: 03-September 11

Re: could not open a connection to SQL server

Posted 27 January 2012 - 09:49 PM

It appears that what you have is done correctly, I personally like to space out my code so a quick vb equivalent would be something like
 dim dbconn as new sqlconnection
dim connstr as string="BLAH CONNECTION STRING CRAP HERE"
dbconn.connectionstring=connstr
dbconn.open()



So, for C# I would use this
            SqlConnection dbconn = new SqlConnection();
            string connstr = "CONNSTR stuffz here";
            dbconn.ConnectionString = connstr;
            dbconn.Open();


Are you able to access the database through the built-in Server Explorer in VS or is it simply not accepting any connections? This works for me so I hope it helps you. Otherwise check to see if your connection string is in the correct format. If that still doesn't work, I'll be happy to help :)
Cheers,
-Yo!

This post has been edited by Yo!: 27 January 2012 - 09:55 PM

Was This Post Helpful? 0
  • +
  • -

#3 trevster344  Icon User is offline

  • Slick.
  • member icon

Reputation: 125
  • View blog
  • Posts: 871
  • Joined: 16-March 11

Re: could not open a connection to SQL server

Posted 28 January 2012 - 10:48 PM

View Postnurza, on 21 January 2012 - 08:51 PM, said:

hye there ,
i'm using visual studio 2010 with the languange c# / asp.net
i've make connection to localhost database
so there is my connection string

SqlConnection con = new SqlConnection("Server=localhost;Database=estrategik;User Id=rrrr;Password=rrrr1");


my problem is when i debug the system this error will occur

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

i've try serach on google how to fix this error and i've tried follow the all step from this link
My link

but it still error , i hope u can help me to solve this problem

thanks ,
zah .


if your database is estrategik, how does sql know what that is? estrategik what about the extensions? or the path? If I'm not right please correct me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1