AK47
AK47

Reputation: 11

Asp.net MVC database connection setting in Visual studio 2008

I am trying to learn Asp.net MVC framework. I was looking at the video tutorial at the link below http://www.asp.net/learn/mvc-videos/video-395.aspx In this video the very first step is to add a new database to the example application. I have visual studio installed on my development machine but the SqlServer Express is running on a different machine, so when I try and add a new database following the same steps as the video I get the following error

"Connections to SQL Server files(*.mdf) require SQL express 2005 to funciton properly. Please verify the installation of the component or download from the url"

I am assuming this is because Visual studio is looking for an instance of SQL express on my local machine and since it doesnt exist on the local machine,it errors out.

So how do i tell visual studio, to connect to a different machine and create the database there? I am using Visual studio 2008 with .net 3.5 Sp1

Upvotes: 1

Views: 3624

Answers (6)

Craig
Craig

Reputation: 11

Open the Server Explorer and add a new Data connection. Same thing as adding a new .mdf. You can use it just the same.

Upvotes: 1

Andrew Siemer
Andrew Siemer

Reputation: 10278

Make sure that remote connections is enabled in your sql server express installation (http://www.linglom.com/2007/08/31/enable-remote-connection-to-sql-server-2005-express/). Then take a look at www.connectionstrings.com for the various ways to connect to the sql server as appropriate for your environment. Then configure the connectionstrings section in web.config and reference that configuration target when connecting to the db.

Alternatively you might try using LINQ to SQL which will streamline some of these tasks (still need to enable remote connections and get an appropriate connection string defined...LINQ to SQL wizard for the rest).

Upvotes: 1

J.W.
J.W.

Reputation: 18181

Instead of add a new database to a remote machine as you indicated on your local machine, you can try to create the database on the remote machine firstly, and then connect to that remote database within your visual studio.

Upvotes: 0

Cyril Gupta
Cyril Gupta

Reputation: 13723

I am not going to see the video so I can't tell you what step to change. But it should be easy enough to write a connection string (or get it off the web) that connects to a database on the remote computer and not your PC.

I am so used to writing my own connection strings that I don't even know of any option in VS that automates this.

Upvotes: 0

Joseph
Joseph

Reputation: 25523

What you'll have to do is attach the mdf to the database server you have running on your separate machine, and then open up your server explorer and navigate to that particular machine and select the database from there.

Upvotes: 0

l3dx
l3dx

Reputation: 2955

  1. create the database on the remote computer(edit: IIRC, you can also create it within visual studio when you add the connection)
  2. ensure that it allow remote connections
  3. add the connection in database explorer

I'm not sure what's happening in that video, but if you for instance are going to use linq2sql, visual studio will add the connectionstring to web.config when you drag the tables into the .dbml :)

Upvotes: 0

Related Questions