I got an Error at line myconn.Open(); How to solve it.
{"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:}
SqlConnection myconn = new SqlConnection();
String connection = "Data Source=SQLEXPRESS;AttachDbFilename=C:\\Users\\Winer\\Documents\\Visual Studio 2008\\WebSites1\\App_Data\\Database.mdf";
myconn.ConnectionString = connection;
myconn.Open();
Can any one say about it ?
It just means that the server
SQLEXPRESSwas not found. I think you have a typo error. Try this if it works: (Data Source=.\SQLEXPRESS;)UPDATE 1:
.means or equivalent tolocalhostData Source=.\SQLEXPRESS;is the same asData Source=localhost\SQLEXPRESS;or try
Data Source=YOURCOMPUTERNAME\SQLEXPRESS;UPDATE 2
Why not use this Connection String format?
OR
WHERE
myServerAddress is your server address
myDataBase is the name of your database
myUsername is the username as well as
myPassword your password.
More ConnectionString format on this link.