Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 how do i build a database for use with visual stud

Author  Topic 

shaunzo101
Starting Member

7 Posts

Posted - 2011-04-27 : 07:23:36
Hi,
I am creating a windows form in visual studio 2010, and i am trying to create a database in sql server 2008. I would like the visual studio 2010 to connect to a database in sql server 2008. I spent 3.5 hours searching on how to do this but it just doesn't work.

Specifically, the server will be located on one computer, and the VS2010 is located on another computer. I would like these to connect to each other over a LAN - so when using the windows form, it will use a database running on SQL server 2008 running on another computer. The purpose of this is for an academic project. Can anyone offer me advice as to how to approach this? Any/all advice will be greatly appreciated! :)

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-27 : 07:30:37
Look at these three pages in order:

Creating a database: http://msdn.microsoft.com/en-us/library/ms186312.aspx
Creating a login: http://msdn.microsoft.com/en-us/library/aa337562.aspx
Connecting from VS using ADO.Net: http://msdn.microsoft.com/en-us/library/dw70f090(v=vs.80).aspx

Also, http://connectionstrings.com/ is a useful site for looking up connection strings.

If you get stuck somewhere along the way, post the error messages and your code with enough information that will allow someone to reproduce the problem. There may be pitfalls along the way that I am not seeing or describing.
Go to Top of Page

shaunzo101
Starting Member

7 Posts

Posted - 2011-04-27 : 07:39:10
Excellent stuff, i will look into this and see how i go.
Go to Top of Page

shaunzo101
Starting Member

7 Posts

Posted - 2011-04-27 : 08:20:10
I don't really understand the code, is there a GUI based method of connecting the database in sql to VS?
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-27 : 08:48:28
This page http://msdn.microsoft.com/en-us/library/fxk9yw1t(v=vs.80).aspx

Also look at the link on that page to How to: "Create Connections to SQL Server Databases".

Visual Studio is really a programming environment, and while it does provide some GUI tools for common tasks, it would be difficult to get very far without understanding the code.

Go to Top of Page

shaunzo101
Starting Member

7 Posts

Posted - 2011-04-27 : 09:37:01
Ok, so we have set up an ad-hoc network to connect the two laptops

Lets say:
My laptop which is called SHAUNLAPTOP: is running the Visual Studio project
and the other laptop JOHNLAPTOP: is running our SQL server management studio.

On SHAUNLAPTOP, within the data source config wizard we go Database -> Dataset -> New Connection -> Change -> Microsoft SQL server -> OK -> Server name: we click on the other laptop which is listed in the dropdown list as JOHNLAPTOP

The problem is: where it has 'Select or enter a database name:' nothing appears in the list. Do you know why nothing appears? If i do it using SHAUNLAPTOP as the server name (the laptop containing our VS project) all the databases in the sql server appear (please note i am running a copy of sql server 2008 on SHAUNLAPTOP as well just to test things out but we want to access the sql server on JOHNLAPTOP). But once we select JOHNLAPTOP from the Server name dropdown box, nothing appears in the 'Select or enter a database name' drop-down menu. How come we can't see the databases after selecting JOHNLAPTOP?
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-27 : 10:09:19
Are you logging in as the same user in the same domain on both computers? If not, try that, and if that works, that is an indication that the other login/user has not been added to the server/database.

If you are logging in as the same user and still not able to see the server on the other computer, check if you have "Allow remote connections" enabled. In SQL Mgmt Studio, if you right click on the server and go to properties, under Connections you should be able to see it and/or change it.
Go to Top of Page

shaunzo101
Starting Member

7 Posts

Posted - 2011-04-30 : 00:12:16
We have solved the problem. Turns out you need to select named pipes from within Visual Studio under the advanced menu when connecting a database.
Go to Top of Page

TaaviM
Starting Member

1 Post

Posted - 2012-02-19 : 09:18:09
quote:
Originally posted by shaunzo101

We have solved the problem. Turns out you need to select named pipes from within Visual Studio under the advanced menu when connecting a database.



I registered in this forum just to say many thanks!
You're Awesome! I don't even remember how long i have struggled with this problem already but now it works
Go to Top of Page
   

- Advertisement -