Error Connecting In Application Code to Database (Yet Test Connection was fine)
Hi. I am using Visual C# Express 2010, Windows XP
I'm attempting to connect to a database within my application code after performing a successful Test Connection when setting up a new Data Source.
I'm using one of the database options available from my drop-down menu, I believe SQL Server Express 2010 or something of another. It came with visual C# express and is installed locally.
When calling [myConnectionVariable].Open() in my application code, I get the following error:
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)
What could be causing this? I checked the Settings file and saw something called "Data Source=|DataDirectory|myDataBase.sdf" Am I supposed to change DataDirectory and put in the full directory address, or is there something else causing the server to not be found an accessible?