Connect to Microsoft SQL server 2008 (enterprise) database from Visual C# 2008 Express (Test connection failed)

Posted on 2008-11-07
Medium Priority
Last Modified: 2013-12-17
Hope someone can help with this problem...

Using Visual C# 2008 express and SQL Server enterprise 2008
running on a laptop (vista home .premium)

i've created a new database using SQL server managment studio with no problem.
database via Management Studio there is no problem, the
database appears in the Explorer.

however, in Visual C# Express, when I try to 'Add Connection' as follows

Data source - MS SQL Server Database File
Database File Name - browse to appropriate folder and select
Log in using WIndows Authentification

and use the same database I receive the message (after a while):
"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)"

and yes i did detach the database / disable windows firewall / shutdown anti-virus sw before i try to connect.

* also, let me say i manage to connect for OLE DB (Access 2007) with no problems

does visual c# express edtion got to do with this problem, i mean if full version of visual studio can solve the problem ?

Looking for a solution if possible for the SQL server 2008.

Question by:turki_00
  • 4
  • 2

Expert Comment

ID: 22911038
Usually you should choose SQL Server, not SQL Server Database File, as the data source, and choose the instance name you've installed; that way you shouldn't have a problem. The 'database file' option is used in other cases (attach a file to a server instance).

Author Comment

ID: 22913015

i only have 3 choices for the data source:
1. Microsoft Access Database File (OLE DB)
2. Microsoft SQL Server Compact 3.5 (.NET Framework Data Provider for Microsoft SQL Server Compact 3.5)
3. Microsoft SQL Server Database File (SqlClient)

this is why i did chose the 3rd option (MS SQL server databse file)
is there a (driver) i need to install for SQL server 2008 ?  (i did mention that i've installed sql server 2008 enterprice edtion on my machine)

Author Comment

ID: 22913026
this is a snap shot of the problem
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

LVL 41

Expert Comment

ID: 22915084
The Express Editions doesn't support a connection to a "real" SQL Server.  
However, you can still connect to SQL Server if  you code all of the pieces "by hand".   Admittantly, you won't be able to use the newer TableAdapters, etc.

Author Comment

ID: 22925800

so you are saying that to connect to sql server (i don't know why did u refere to it as "real") i have to get rid of the express edition and get the full version of visual studio. right ?

LVL 41

Accepted Solution

graye earned 500 total points
ID: 22926142
The full version of Visual Studio provides support to SQL Server, so an upgrade will definitely solve the problem.
The comment about "Real" SQL Server, means that you can connect to the server itself (rather than just the SQL Server files)
I have heard of folks who just bypass the connection wizard and code the connection to the SQL Server "by hand".   Using this technique,  you *can* use C# Express to connect to a SQL Server... but you've got to do all the work.

Author Closing Comment

ID: 31515371
Thank you for the help

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Screencast - Getting to Know the Pipeline

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question