Click here to Skip to main content
16,020,080 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to use SQL Server 2005 Database in my application, i.e: for a website and a windows application. Right now I want two connection string; one for windows application and the other for my website.

My database is hosted in let's say: www.xyz.com

1. I want to host my website on a web server which is done in ASP.NET. So what will be the connection string for that.

I used this as the connection string for my website:
Data source=.\SQLEXPRESS;AttachDBFilename=|DataDirectory|Test.mdf;Integrated Security=SSPI;
and it worked fine in my local computer but when I hosted it in the web server the following error arises:

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)


2. My SQL Database is in the web server. I want to connect it through windows forms application from my local computer using vb.net. So what will be the connection string for this.

I could not understand what to do.
Please someone tell me what will be the correct connection string.
Posted
Updated 7-Feb-12 23:19pm
v2

In SQl Server Configuration Manager choose SqlServer Network Connection, Protocols for SqlExpress, enable TCP/IP.

Also check in Sql Server Services what the name of the SqlExpress Instance is. It might be another name
 
Share this answer
 
Comments
Babamani 8-Feb-12 5:21am    
Thanks for replying..
But my database is in a domain let's say : www.xyz.com. So how to do that. Please help me.
Herman<T>.Instance 8-Feb-12 9:34am    
use the IP address of that server
see
http://www.connectionstrings.com[^]
and other simple way to create connection string use these steps


For connectivity in visual studio 
open Server Explorer
right click add Connection
Follow simple steps
After Creating Connection Right click on Database//Solve error if any
Click on properties
In Proprties Connection String will be found.
Copy This String.


Check you have allowed remote connection see
configure SQL Server 2005 to allow remote connections
 
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