Quantcast
Channel: SQL Server Setup & Upgrade forum
Viewing all articles
Browse latest Browse all 7696

unable to connect to sql server 2008 r2 through vs2010 express

$
0
0
You cannot vote on your own post
0

I dunno if this is the right forum to ask this question.

I am running on windows 7 and I have installed sql 2008 R2 with sql management studio. Then I installed vs2010 express.  I am able to connect to the db through windows and sql authentication through sql server management studio (SSMS) and create a db. But in C# , I am unable to connect to the db through the database explorer.

when I goto Database explorer, right click on data connection, I can see only add connection which is not grayed out. From here no matter what I do, I cannot connect to the server. Infact I get  I get a dialog box which contains a Datasource listbox, Data provider combo box. The datasource listbox has 3 options

1. Acess database file,
2. sql server compact 3.5 ,
3. sql server database file

while the combobox changes according to the content of the listbox


I selected sql server database file in the list box and then in the combo box .net framework data provider for sql server get's selected. I click on continue and I get a dialog window which has

1. edit box with a browse button called as "Database filename (new or existing)"
2. A group box "Log on to Server" with two radio buttons "Window Authentication" , "Sql authentication"
3. Advanced button
4. Test connection button

I then typed the  name of my db into the database file edit box "emp" . As windows authentication was selected, I clicked on test connection and I got

"This connection cannot be tested because the specified database file does not exist."

I checked it I have selected the correct instance in the Advanced button dialog.
So I browsed to the mdf file which contains the data under the programs file/mssql server/.../data folder and selected the mdf file. I got a message that I don't have the permsssion to open this file. contact the file ownder or an administrator tobtain permission.

Then I right clicked on C# and selected run as administrator.  Then I was able to select the file from the data directory folder and open the connection and the database was visible in the Database Explorer. As I was trying to work on Linq on SQl, I added a linq to sql class and I clicked on the dbml file. Onto this I dragged and dropped the table from the database explorer. I got a message,

The connection you selected uses a local data file that is not in the current project. Would you like to copy the file to your project and modify the connection?If you copy the data file to your project, it will be copied to the project's output directory each time you run the application. Press F1 for information on controlling this behavior.

I clicked on Yes.

Now I got

Connections to SQL Server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer.  The current version of SQL Server Express can be downloaded at the following URL:http://go.microsoft.com/fwlink/?LinkId=125883

I went to link mentioned above and I saw that I have the same thing installed.

Please tell me how to connect to the db from database explorer without doing all this circus and what's with the error message above ?


Viewing all articles
Browse latest Browse all 7696

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>