Reputation: 117
I want to connect SQL Server in my webform program.
I use this command :
Connection = new SqlConnection("server=sharmi-PC/MSSQL2012;database=PeopleDb;trusted_connection=true");
but I get an error :
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in PeopleManagement.BusinessLogic.dll
Additional information: 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)
My server name in SQL Server is
sharmi-PC\MSSQL2012
Upvotes: 1
Views: 174
Reputation: 754268
If you say yourself that your server name is
sharmi-PC\MSSQL2012
then why aren't you using that in your connection??
Use this:
Connection = new SqlConnection(@"server=sharmi-PC\MSSQL2012;database=PeopleDb;trusted_connection=true");
Use the proper notation for server/instance name - a backslash (as in sharmi-PC\MSSQL2012
) - not a forward slash as you used (sharmi-PC/MSSQL2012
) ....
Upvotes: 1