Click here to Skip to main content
15,884,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
good afternoon,

i am trying to connecting to sql server which is present in visual studio 2010.

I am giving the connection string as

SqlConnection con = new SqlConnection("Data Source='RajasekharServer';Initial Catalog=RajasekharDatabase;User Id=scott;Password=tiger;");

it is showing the error message as

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)


it is not connecting to sql server which is present in visual studio.

please help me.
Posted

Check your connection string there will some issue and put connection string in Web.Config

<connectionstrings>
<add name="DatabaseLog" connectionString="Data Source=DataSource;Initial Catalog=XYZ;Persist Security Info=True;User ID=ABC;Password=ABC" /> <connectionstrings>
 
Share this answer
 
Try to get the appropriate connection using visual studio 2010 database connection wizard.

In the menu, go to Tools
-> Connect to database
-> A popup will appear
--> type the server name
--> use sql authenticaltion mode if configured
--> a list of database will appear, select your desired database.

Now, go to Server Explorer, your database will appear in the list, right click on it, a property window will appear under that you can see connection string

Just copy that string and paste in web.config file

Hope this will help
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900