Home » Visual Studio

connecting to my sql express database from vs express 2010???

i have asked this question before. I have set up databases with dream weaver and mysql, this cant be more difficult?

9 Answers Found


Answer 1

Data menu -> Add new data source, then go through the dialog steps to identify and connect to your SQL Express database.

Answer 2

I'm not sure why I have not got an answer to this question. I have gone back and forth with this question sense June of last year. It cant be that I have not asked the question correctly. Once I asked If I bought a brand new computer, then installed the latest versions of visual studio express and sql server express. How would I connect from vb to sql? that thread got no answer. I asked again in December and got no answer. I have used dream weaver, php, and mysql. and made a functional e-commerce website. I can tell you that I don't like technology making everything stupid with wizards and such. I don't mean to seem like a jerk, but all I want to do is start building my program. That is all! yet here I am still pulling my hair out. I'm 23 years old I'm an L1 master automotive Tech. I rebuild transmissions. I'm not an idiot. and I'm not stupid. I obviously am not getting along with the way microsoft does things. I i'm not good at learning by just being told to click this or enter here. I am a detailed learner. I like to know what, how, and why things work the way they do. I;m not interested in servers though I just want to build an application that runs 90% with the database. I dont know if this explains anything. Or if it will help someone help me? I am more than willing to swap for my automotive advice.

Answer 3

Hi Andrew.M,

What is the database you use exactly? MySql or Sql Server?

Open Server Explorer of Visual Studio, you can add the database from there.

To access the database from your application what you need is to know the connection string and use it in your VB.NET code.

Hope this helps. If you have more questions let us know (in detailed please)


Answer 4

I have VB express 2010, and sql server management studio(all microsoft free express versions). Its all local. Everyone is talking like its so easy, the wizard wants me to look for a file? I'm used to connecting to the server. I "data sources" witch i believe is the same as "server explorer".

Answer 5

I have VB express 2010, and sql server management studio(all microsoft free express versions). Its all local. Everyone is talking like its so easy, the wizard wants me to look for a file? I'm used to connecting to the server. I "data sources" witch i believe is the same as "server explorer".

Hi Andrew.M,

No, everyone is correct it's so easy :-)

As I said Server Explorer of Visual Studio .

Within Visual Studio, go to the toolbar, then choose View --> Server Explorer.

Once you have added a connection in Server Explorer you will be able to use it in any Data Source.

Hope this helps.


Answer 6

here is how i got it to work before you posted, I went through the "add data source" selected "database" ex. Then selected my .mdf file. said i did not have permission. so i closed out and ran as admin. then it said no because another program was using the file. so I stopped the sql server through services. then it couldn't connect. so then I started the server and everything is working fine. It did say it had to copy the files or something?

Answer 7

It sounds like you selected "Microsoft SQL Server Database File (SqlClient)" as your data source, which probably made a *copy* of your MDF file and put it in your project folder.

If you want to connect to your SQL Express instance, you need to change the data source to "Microsoft SQL Server (SqlClient)".


Answer 8

Hello Andrew,

You can try to follow steps mention below to see if they help:

1) Open Server Explorer (View -> Server Explorer)
2) The Server Explorer should show up on the left hand side of the IDE
3) Right click on "Data Connections" and select "Add Connection". Choose 'Microsoft SQL Server (SqlClient)' in the Data source filed in the prompted dialog.
4) Enter the Server Name in the first textbox (do not use the drop down box). MS SQL Server name can be found in the database manager section of the control panel.
5) Specify the log on mode based on your database
7) Select your database from the dropdown list.
8) Click "Ok"
9) Once connected, you should see a new entry in the Data Connections Section .

In addition, you could also post it on Data Platform Development Forum(http://social.msdn.microsoft.com/Forums/en-US/category/dataplatformdev) so you can get better and quicker response as this forum here is for the setup and installation of visual studio.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.

Answer 9

Hello Edwer Fang!

I have the same problem, but I can try to follow steps you posted. Because there are no "Microsoft SQL Server (SqlClient)" data source on Visual Studio 2010 Express C#, there are only "Microsoft SQL Server Database File (SqlClient)". So I try to find "Microsoft SQL Server (SqlClient)" data source for C# Express 2010. After some days finding, I can't find any document or guide mention the problem.

I wonder that maybe the data source didn't support for visual studio 2010 express 2010 C# or there are some happened wrongs during installing (but Web is stilling)


Good day Sirs,


As the title is saying, I cant seem to connect to my SQL Server Express Database using "sqldatasource" control in Visual Web Developer 2010 Express

Steps Taken:

clicked "configure data Source" option in the Sqldatasource

then "New Connection..."

Changed my Data source: to " Microsoft SQL Server Database File (SqlClient)

Here comes the problem:

1. I am choosing a Database file name but a problem keeps on popping:

    "ServerName This file is in use: Enter a new name or close the file that's open in another program"

2. Then I tried to choose a detached database file (mdf) and it was attached now another problem pops:

   "ServerPath cannot be opened becuase it is version 661. This server supports 655 and earlier.


I am using windows Home Edition: does it contribute to my problem?

My server and VWDE is in the same equipment(laptop)


Does anyone have an idea why is it like this?



I need some help here.  I have a small network and due to need have to load SQL Server 2008 R2 Express on my domain controller, which is running 2008 R2 Server.  I know that this is not an ideal situation but it is what I have to deal with at this time.  I am having an issue where when I do the load of this software it will finish with errors and I am unable to connect to the Database Engine, it is giving me a 18456 and/or 18461 errors when I try to log into that piece.  I have the Management tools package installed as well.  Due to the environment in which I work I cannot upload any logs though I can provide specific errors if needed.  If anyone has any ideas please let me know asap as my deadline is quickly approaching.



First off, I don't know much about networking which is probably why I am having problems. I do know that I have two computers that connect to the internet via a router. The IP of the computer running the SQL Server is and the computer name is SEAN. The other computer is the one that is trying to connect to the SQL Server; it is named MATT and it's ip is From MATT I can ping and also I can ping this machine by typing 'ping sean'. When I do this it starts off by saying 'Pinging sean.gateway.2wire.net' etc. From SEAN I can ping and also I can ping again using 'ping matt' but this time it says that I'm pinging a loopback each time instead of matt's ip. Also here, matt is listed as 'matt.gateway.2wire.net'. I am hoping this background info is useful :-\. So the problem is, from my .NET application running on SEAN I can connect to the SQL Server running on SEAN (SEAN\SQLEXPRESS), but when I run the same .NET application on MATT, I have been unable to do the same. These are the connection strings I have tried:

Data Source=\\SEAN\SQLEXPRESS;Initial Catalog=SmartBidDatabase;User ID=sa;Password=SmartBid

Network Library=DBMSSOCN;Data Source=,1433;Initial Catalog=SmartBidDatabase;User ID=sa;Password=SmartBid

Server=Sean\SQLEXPRESS;Network Library=DBMSSOCN;Data Source=,1433;Initial Catalog=SmartBidDatabase;User ID=sa;Password=SmartBid

I'm not sure if I'm doing something completely wrong with the connection string of if the network setup is getting in the way. With the last connection string I made sure to go into My Computer -> Manage -> Services and Applications -> SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for SQLEXPRESS -> TCP/IP , and enable it with a port # 1433. Oh, and both computers are running Vista with no firewalls on (not even Windows Firewall). Any help on this issue will be GREATLY appreciated.



I just bought a new computer, so I decide to install the 2010 Express version of everything.  But I cant make C# connect to my Sql database located at on my on website.  I just connected to it via Mananagement console, so I know its there and working. 

I read one posting comment that Im going to have to purchase VS.  If thats true, Im going back to my old version of Visual Studo.



i dont want share point server 2010 to create another instance of sql express 2008 r2, i want it to use the exiting one SQLEXPRESS but i dont know

what installation option to do and what settings to do ? im installing share point 2010 on windows 2008 r2 server




I recently installed Visual Studio 2010 and was getting the following error message when running the code (F5) "Error connecting to SQLexpress". The error page prevented me from seeing the webpage.

I consulted many different trouble-shooting recommendations, however, in my case, it was simply a problem with SQL. When I reinstalled SQL server 2008 on my computer, the error message was gone and I was able to see the ASP.net web development page.




I'm using MS Visual Web Developer 2010 Express to build a website that connects to a SQL server 2000 database.  Is it possible to connect to SQL 2000 using providerName="System.Data.SqlClient"?  I'm guessing not.

Or am I limited to using providerName="System.Data.OleDb" ?   And seems both connections are under this ADO.NET umbrella. Please confirm one way or the other ... I'm a bit confused.

 From web.config:

    <add name="SubscrTypeConnectionString" connectionString="Provider=SQLOLEDB;Data Source=my-server-host;Persist Security Info=True;Password=123abcde;User ID=test;Initial Catalog=Apps"
   providerName="System.Data.OleDb" />

So I believe I need to use OleDbCommand calls. I've seen many examples to do gridview select/edit/delete using SqlClient but not OleDb calls in VB code. Links to sample code would be great.

Thank you!



Couldn't even get 2008 installed, or at least not sure, because I ran the installation program SQLEXPRWT_X64_ENU and then there seems to be no program I can run like there was for 2005. Anyway, once I get to where I can actually run 2008, I have a DB on 2005 on a hard drive that used to be with an XP machine running SQL Server Express 2005, now in a new computer running Windows 7 64-bit with (soon to be) SQL Server Express 2008. I need to import (extract?) the database from the hard drive without the benefit of running 2005 (don't have that program installed on the new machine) into a 2008 database.

Please help.


Database error: Cannot connect ot Database: [Microsoft][SQL Server Native Client 10.0][SQL Server]Server name cannot be determined. It must appear as the first segment of the server's dns name (servername.database.windows.net). Some libraries do not send the server name, in which case the server name must be included as part of the user name (username@servername). In addition, if both formats are used, the server names must match.
ODBC Error
Session halted.


$host = "tcp:s6s1aw1dwr.database.windows.net";
 $dbname = "internet";
 $dbuser = "skytech@s6s1aw1dwr";
 $dbpwd = "******";
 $driver = "{SQL Server Native Client 10.0}";


let me know what could be the reason ?


using c# 2010 express & SQL server 2008 express.

when i right click on project name -> add -> new item, there is no SQL database to select

the book i'm using to learn c# tells me to do this.

what do i need to do?


I am able to run crystal report on vs 2010, whenever i run report it ask me to enter details e.g server name, database name and sa password. then it connects and brings the report. this shouldnt happen,  i want to do it programatically.




Setting up a new install for a client who will be using SharePoint Foundation 2010 in Standalone mode. They do not have SQL SERVER 2008 so need to utilize the Standalone option and the latest version of SQL Server 2008 Express R2. They are just getting started with SharePoint and it is unknown how much the technology will be embraced to afford to purchase SQL Server at this point. I wanted to get that explanation out of the way before everyone tells me the best practice of installing in Farm mode only! I realize the best practice but sometimes we have to roll with the punches because getting a client to begin using SharePoint on their current budget is better than never getting the chance to use it at all.

So SharePoint Foundation 2010 is installed with the default SQL Server 2008 R2 Express instance. Is there a procedure for moving the databases to a new drive? What is the default instance name that is created? I'm having a hard time locating that information in the documentation. I've done this before with WSS 3.0 without issue but wondered if there were any documents on moving the newest databases and what the default instance name is. Thank you in advance.


Can I upgrade SQL express database to SQL server Standard database? Please give information to me! Thank you!

I installed VB 2008 Express with SP1 and SQL 2008 Express. However, I cannot link to SQL 2008 Express from  VB 2008 Express. Please Help.

Since I'm new to this environment, I may not even be asking the right question. A brief background: I did some minimal work with VB 2008 Express - creating an sdf database and some forms that interacted with the database. I also did some minimal work with SQL 2008 Express, running some queries against the AdventureWorks Database. When I tried to create a form in VB 2008 Express that accessed the AdventureWorks Database in SQL 2008 Express, I have been unable to figure out how to create the needed connection.

I cant conect to sql server from C#. When  I try to add a new connection I get this error
"A network-related or instance-specific  error occored 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 configures to allow remote conections.(provider:SQL Network Interfaces, error:26-Error locating Server/Instance Specified)"

When I try to add a new connection using SQL Server Authentication i get this error:
"Faild to generate a user instance of SQL Server. Only an intergrated connection can generate a user instance. The connection will be closed.

Some times i get this error:

"You don't have permission to open this file.

Contact the file owner or an administrator to obtain permission."

I am the owner of the file and the file is on my computer and I am log on as the administrator and the sql server and c# are located on this admin account.
i have asked this question before. I have set up databases with dream weaver and mysql, this cant be more difficult?
I've believe I've installed everything to read Mobile SQL .SDF files.  I've insalled Sql Server Management Studio, Sql Server 2008 R2, .NET 4.0 Framework and just about everything else I've read to see the contents of an .SDF file created for what I read directly from these product sources as this DotNet Compact Framework is the greatest new SQL stuff on the planet.  I can connect using the Management Studio and see the TABLE Stucture easy enough and I can query using some simple SQL Commands from the Management Studio but what really bugs me is if this is all so wonderful, how come I cannot connect to what the SQL Server 2008 R2 Server type "SQL Server Compact" Authentication: "SQL Server Compact Authentication in Office 2010 Access, Excel or even "WOW" PowerPivot!  I've run across a couple 3rd party .SDF Readers - one that exports to Excel such as flyhoward.com  I'm growing old with all the work around import export stuff and just want to use PowerPivot to  excersise the data......or should I use something that actually works like Tableau??


I just installed SQL Express 2008, and for some reason I've 2 instances.


when i try to connect to via SQL authentication, it works.

when i try to connect to\SQLEXPRESS via SQL authentication, it doesn't work, but it works for windows authentication.

how can i fix it? i want to connect to\SQLEXPRESS.




I have WSS 3.0 installed on a server with SQL Express 2005 as the database. I tried installing Search server express (SSE) 2008 on the box. SSE installs, but in the search configuration page in central administration, i get an error as below

"Search Server has detected that the minimum database server version requirement is not met. The computer that hosts the database server role must have Microsoft SQL Server 2000 with SP3a or later or Microsoft SQL Server 2005 SP2 or later."

The technet article doesn't mention anything about the minimum database requirements.


Can Search server express be installed with SQL Express 2005/2008 as the database? Do we need to go with SQL 2005 full version?


About 5 days ago I downloaded SQL Server 2008 R2 Express. I had some trouble and eventually ended up removing both SQL Server 2008 and SQL 2008 R2 Express and then reinstalling R2 Express. After doing so I couldn’t get Visual Basic 2010 Express to recognize my on-computer databases used with my applications. I get the error message "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed." It worked before I downloaded R2 Express.

I can use R2 Express including Management Studio and make new databases, I can access my computer-based databases, but I don’t know how to get Visual Basic 2010 to work with it. I’m retired and use Microsoft’s Visual Basic 2010 Express, SQL Server 2008 R2 Express and Web Developer 2010 Express for my personal enjoyment. I have a personal website but don’t use a database with it, so I only use the server as a local-host for my Basic applications or projects; what do I need to do to use it as such?


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure