Creating a Database Connection to a Remote SQL Server Database within Visual Web Developer

By Nannette Thacker

Step-by-step instructions for creating a database connection to a remote SQL Server Database, using Visual Web Developer.

  1. Go to the View menu item and select Database Explorer.

  2. Depending on how you have your Visual Web Developer interface setup, go to the Solution Explorer, and at the bottom you will see a tab for Database Explorer. Click that. 



  3. You will see the "Data Connections" available in the Database Explorer. We currently have none displaying.

  4. Right click in the Database Explorer area and select "Add Connection..." 



  5. This will bring up the Add Connection dialog box. Select the "Change" button. 



  6. In our example, we are connecting to a SQL Server database, so select the "Microsoft SQL Server" Data source option as well as the ".NET Framework Data Provider for SQL Server" Data provider. 



  7. Select "OK" to return to the "Add Connection" dialog. Put in the IP address or server name for your database. In our case, we use Windows Authentication, but you may optionally input a User Name and Password and select "Use SQL Server Authentication." Use the drop down list to "Connect to a database" and "Select or enter a database name:" Select "Test Connection" to make sure you have it setup properly. Then "OK." 



  8. Now you may use the Database Explorer tab to view your tables and data. 





Although you may create and alter a SQL Server .mdf database within your project, Visual Web Developer doesn't support opening a table definition or adding a new table from your SQL Server 2000 database. But it does allow "Show Table Data." It allows you to see the names of your stored procedures, but not to edit or view their content, just the properties. It is very limited, but you may wish to have it just for those purposes.

If you don't yet have the new Visual Studio, but do have Visual Interdev, perhaps for use with your ASP Classic development sites, you may utilize VI to manipulate your SQL Server databases remotely.

May your dreams be in ASP.net!

Nannette Thacker

74 Comments

  • Is this a joke?

    Is this what passes for content on weblogs.asp.net now?

  • Was this really worth posting?

  • Josh Anon,
    It's fairly obvious that I put effort into my blog. I think some people seem to forget that the internet is full of newbies learning how to program and use the tools. I like to provide step by step instructions to aid others in learning things that you evidentally feel are uselessly beneath your level. Just congratulate yourself that you're beyond that stage and move on.
    Nannette

  • @ Josh + @ Anon

    If you were smart and experienced enough, what made you read this blog. You should have easily neglected it.

    It takes time and effort both to take the snapshots and to post it.

    Pl. take the positive side that nannette is trying to help the newbies.

    Carry on nannette, few odd remarks should not change your attitude.

    P.S.:- it would be nice, if you can explain how to create a database on the remote server, and how to take the backups.

    All this should be through Visual Web Developer.

    Would it be more easy through control panels or VWD..?

    Pl.guide us.

    WebReservoir

  • WebReservoir,

    It is my understanding that VWD doesn't support creating a database or making backups on the remote server. At least when I work with VWD on my remote database, it is very limited and doesn't allow manipulation, just viewing.

    Anyone else know for certain?

    I do have an upcoming article coming out on 4guysfromrolla that will demonstrate how to create an .mdf database in VWD, but that's not what you're asking.

    Thanks for your kind words WebReservoir.

    Nannnette

  • Nannette ignore the trolls. Great article for the beginners out there.

  • I'm a newbie and this was useful as it's what I searched for in Google.

  • I also appreciated the beginners step-by-step. Not all of us have been programming .Net for years. This post was able to get me jump started on a project I'd been putting off because I'd had problems connecting to a remote DB. Thanks for all your work.

  • Nothing wrong with what you provided Nannette.
    Good job mate.

  • Nannette,thanks for the tip. I've been doing application development for decades (I won't mention how many) and have had to learn and use dozens of languages and development tools. In this time and place, I am a newbie, and I appreciate your efforts.

  • this was very useful to me

  • Nannette,
    As a newbie to asp.net, I appreciate your article. I am new to VWD and was uncertain how to make my connection.

    Now I'm working with my data and learning how to represent it in VWD.

    Thanks a bunch!

  • I'm a newbies myself and this helped me out quite well
    Nice one!

  • Great post for us newbies it is very much appreciated that the more experienced will still take the time to do something like this.

  • Very Good work. It is help full for anyone who want to quickly know how to connect to remote sql server. Keep up the good work. And hope that others will follow your example instead of criticizing it.

  • Nannette,

    Thanks again, it was appreciated here too.

    Dan

  • I agree, great post.

  • Great Post. Thanks for taking the time

  • Thanks Nanette, very helpful!

  • Man, this tutorial was such a waste of time. I can't believe this made it to weblogs.








  • Thanks Charles, for your kind words.

  • This was very helpful to me. I am just starting out and this answered my question exactly! Thank you so much Nannette, you really helped me out today.

  • Jason,

    I believe in this example I was using Visual Web Developer 2005 Express Edition.

    In all of my instances, I do simply use the IP address.

    Have you made sure you can access this database remotely from any other type of method you've successfully used? Perhaps you need to grant permissions in your firewall.

    In my situation, I use windows authentication, so the user I log in with must also have an administrative account on the remote SQL Server box.

    You might try using a login and password and see if that works. Then if so, perhaps track down why the windows authentication doesn't work.

    Nannette

  • Good simple post actually, I found it useful, being new to VWD 2008 Express. And your note that it does not allow the user to Create a new Database from within definitely saved me a lot of hair scratched off my head.

    Now the next question is, then how do you actually Create a new Database then (since I have no other database administration tools at the moment, what is recommended)?

    SIDE NOTE:
    Also, after I chose data source to be ".NET Framework Data Provider for SQL Server", the Server Name drop down box automatically gave me a list of the server instances I have installed locally, so there is no need to type in the IP address.

  • Kang,

    >>how do you actually Create a new Database then

    I guess what I meant is, you can create a local .mdf database and alter it. But you can not create a remote SQL Server 2000, 2005 or 2008 database on a remote server from within VWD Express.

    From what you said, sounds like you're working locally, so that should work for you.

  • yea, useful post indeed. its exactly what i needed to know. thanks a lot.

  • Thank you for the post.
    This was very usefull. I have been using ASP.NET for a couple of years now, so I don't consider myself newbie. But because I am only connecting to a database on our server I didn't know how to do it on a remote db. I learned how now, although it's very easy.
    Thanx again

  • Great post. Thank you.

  • Thanks for the post. I was extremely frustrated trying to do this as a newbie. keep on posting for us, we appreciate it.

  • Thanks for this tutorial. I am a newbie and it is great to find tutorials for beginners like me - especially where they are complete with snapshots.
    Well done.

  • A good one, The ones who dont think it worthwhile could ignore this. But they dont have to discourge anyone. let em all come upto ur level.

  • This article helped me to get SQL server 2008 running on my computer. Nannette put a great deal of effort into this article. Please ignore all the negative comments. Thank you

  • Hi

    I followed steps you provided ,but i'm not able to connect to remote database by giving ip address.I'm gettin error as remote connections is not allowed.But i had enabled that one.

  • Hi

    I followed steps you provided ,but i'm not able to connect to remote database by giving ip address.I'm gettin error as remote connections is not allowed.But i had enabled that one.

  • You have use IP address but i want to enter server name.How to know what is my server name.I m using visual studio 2008.

  • Thanks for posting this article.

  • NANNETTE!

    AWESOME Instructions! Thank you.

  • Its was vry nice for newbies...it helped me alot.. But can u please explain me about windows authentication in "Add connection" dialog Box.How could v know about server name??plz explain me

  • THX nannette! I'm using Web Developer for 2 years and never realized that remote connection is so simple lol :D

  • thanks, i needed to this!

  • This topic was very helpfull to me as i am a new in asp.net+sql. many many thanks. more topics may ple be posted like this in aspx+SQL database

  • I like instructions that are step by step. In a past life I was required to write instructions for colleague with limited knowledge. I have also had the pleasure of knowing many "Computer People". Most lack tact, attention to details, respect and valuable communication skills. This could be why most are lazy, over weight, lonely and possess very strong left arm.

    Keep up the good work.


  • Thanks Nannette. Much appreciated.

  • still nowadays good job!

  • tis goog.bt it needed some experience about programming also.........
    thanks

  • Thank you very much, I've been having tons of problems with a remote database in SQL Server and couldn't find the cause. Without you I would have never been able to connect to the database and find that the original data was a spanish Ñ in the data, since I was receiving it already altered by the C++ connector encoding.

    Thanks a lot, there aren't many posts like this one, useful for a newbie like me.

  • Thanks a lot. this really good..

  • You can use SQL Server Management Studio Express to create a database and tables on a Remote SQL Server.
    David

  • Hiii,
    thnx for the post but I don`t know why these steps are not working with me.
    I just choose my pc as the server and check "use sql authentication"
    enter in user name "sa" and password"mypassword"
    and then Login failed for sa user.I wonder why this happens with me

  • Disculpa, no podrias poner el codigo de la conexion a otra base de datos remota desde visual basic, creo que eso ayudaria a muchos, muchas gracias.
    Atte. Luis
    Estudiante de Informatica
    COMPUTRONIC

  • very useful, thanks

  • Thanks this is helpful to me!

  • thanks a lot for tips its very good.

  • hi i have created one database project where i want to connect sql server 2000 database from other system from local lan using odbc connection in vb 6.0 please help me

  • Thanks! This was just what I needed to figure out that I needed to instal Microsoft SQL Server.

  • Thanks for the post - VERY helpful for this newbie!
    MUCH appreciated. !

  • Thanks!, This is helpful

  • thanks a lot sir.great n helpful 2..

  • thnx dis really helpful

  • Really its very nice article.

    And this is what I searched in google.

    Thank you very much

  • @Nannette

    Thanx dude it totally helpd me
    Thanx a lot

  • Thank you for posting this how-to. I used it today to connect to a remote database, the first time ever. Bliss. Pride. You the man though! :-)

    Please ignore those who critise you. You're doing good work.

  • I found this information very helpfull!
    Thanks!

  • hi Nannette, ur post about db connection is quite useful but I need codes for a submit button in vwd 2008 to submit data to Mssql express 2005. it is quite urgent. ur help is appreciated.

    please mail to oliottah@hotmail.com

  • I will check this one and I will update the progress guys.


    Kenneth

  • That was really a great..I appreciate nannette for this post n for all the effort she put in takin the snapshots n posting them..N i promise that ur snapshots gave me more great idea of how to connect to the database ..Keep posting Nannnette..U rock ..All the very Best

  • Thank you Nannette. Forgot this method. LOL

  • I've a question.

    I have SQL Server 2000 installed on client machine and my team is writing scripts using PL/SQL .
    We dont want to install SQL Server 2000 in everyone's pc and create database to write scripts.

    Is there any tool which connect to client machine's sql server 2000 and access there database to write scripts.

    Thank u.

  • Madhu,

    I use SQL Server Management Studio. But you can also use Visual Studio, such as VS 2010. Use the Server Explorer tab, select the existing or create a new Data Connection. Go to the Stored Procedure folder of the database, and select to "Add New Stored Procedure."

    Nannette

  • Thank you so much.

  • thanks. no matter what they say, keep sharing.

  • Thankx these snapshot so helpfull for me.

  • its good article.

  • GREAT! GREAT!GREAT!GREAT!GREAT!GREAT!GREAT!

Comments have been disabled for this content.