0

i am a beginner and using mircosoft Sql Server 2005. i connect with Server name : USER-PC on Windows Authentication. now this is creating a serious problem in my Windows Application. i want to use .\SQLEXPRESS in the connection string in my application but doing this creates an error saying:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

m trying a lot to solve the problem but cant find the solution. the connection string i used is:

SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=demo; Integrated Security=true");

please provide solution or link to my problem.

Divyanshu
  • 5
  • 1
  • 5

2 Answers2

0

.\SQLEXPRESS means that you have local instance of SQL Express named as localhost\SQLEXPRESS. If you are trying to access database on server USER-PC then use that like Data Source=USER-PC or if you have a named instance of SQLEXPRESS then use Data Source=USER-PC\\SQLExpress

Habib
  • 219,104
  • 29
  • 407
  • 436
  • can i convert USER-PC as local instance or make a new instance of SQLExpress ?? if so then whats d procedure – Divyanshu Jun 18 '14 at 10:53
  • please help cox i wanna change USER-PC to USER-PC\SQLEXPRESS – Divyanshu Jun 18 '14 at 14:56
  • @Divyanshu, search for [rename SQL Server Instance](https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=rename%20sql%20server%20instance) you might have to install a separate SQL Server Express instance on USER-PC – Habib Jun 18 '14 at 17:48
0

You aren't declaring the name of the database. For example, if your database was called "database1"

@"Data Source=|DataDirectory|\database1.sdf"

Please note this is for a local database in SqlCe 3.5 your database may be serviced based.

Tom
  • 154
  • 2
  • 7
  • 25