How to Create a Data Source in Visual Studio.NET

Category: Visual Studio.NET

How to create a data source in Visual Studio.Net 2005(Part 1)

Welcome, in this tutorial we are going to create a new data source in Visual Studio.Net using the built in wizards and drag-n-drop. To begin go to “File”, “New”, “Project” and name the project something like “MyPubsDataSource” or whatever makes sense to you. This will be a windows application although it’s not really important because we just need any type of project because creating a new data source is commom to all project types. Ok after you enter a name for your project and press the “Ok” button VS.Net will have created your first form for you named “Form1.cs”. At this point the form1 view should be already in design view(If you see a rectangular window that reads “Form1.cs[Design]* then you are in design view.
Ok next click once anywhere on the form and then select the “ToolBox” tab on the left of the design window. If it’s not viewable then select “View”, “ToolBox” from the main menu.(See image below)

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.



[Click to see full-size]


Which will show you the window below.

[Click to see full-size]

Ok, next select the “SQLDataAdapter” from the ToolBox and drop it anywhere onto your form. Once you release it, it does not actually sit on top your form but instead it positions itself just below your form inside the design area. At this point you will have another window in front of you for you to choose your data source like this(See image below).

[Click to see full-size]


If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

On the next window choose Microsoft SQL Server or Microsoft SQL Server 2005 Express or whatever your data server may be. The next thing to do is enter your server name if you know what it is if not press the drop down arrow and select it from the list of providers.(See image below).

[Click to see full-size]

Next, if your server is setup for it then you can choose “Windows Authentication” if not and you know what your SQL Server login settings are then enter the user name and password. Now you want to test your settings and make sure you can connect to your server so click on the “Test Connection” button now.  Next you will get a message box showing the connection status of the test. If it’s ok press the “OK” button and the form will close and you will be back at the Data Adapter Configuration Wizard. Select either “Yes or No” to save the password for your connection in the App.config file. (Please note if you select “No” you will be prompted for it each time you run any of your applications that need to connect to SQL server for data). I normally select “Yes” as I setup a login on SQl Server with only enough rights to handle the data I’m working with.
Ok, now click “Next” to advance to the next screen of the wizard. Here you can use sql statements, use existing stored procedures, or create new stored procedures. For now select “Use SQL Statements” and press the “Next” button.(See image below)

[Click to see full-size]

We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers and add-ons were setup swiftly, in less than 24 hours. We were able to confirm our order over the phone. They respond to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

The next window you will see will be this one.

[Click to see full-size]

Select the “Sales” table and press the “Add” button and then the “Close” button.


The following window will appear below.

[Click to see full-size]

Select the (All Columns) square to place a tic mark and then press the “OK” button to save and close the window. You are once again back at the wizard and now you will see this code in the center.


SELECT        sales.*
FROM            sales
Ok, great, now press the “Next” and then the “Finish” button.  In design view of Form1 just below the bottom of the form right click on the “sqlDataAdapter” and select generate dataset. Just go with the default settings and press the “OK” button. Ok now right click on the “sqlDataAdapter” again but this time choose “Preview Data”. On the form that pops up(See image below) press the “Preview” button

[Click to see full-size]

If you're ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.

You will now see your data in the resulting form.(See image below)

[Click to see full-size]

Ok now just press the “Close button once you are thru looking at the data. Awesome, you have just created your first sqlDataAdapter, SQLConnection, and dataset. You could now use this new dataset in any .Net control of your choice. In the next tutorial we will do just that.
Thank you for taking the time to go thru this tutorial and I really hope that you have gained some knowledge from it. It is my full intention to make these tutorials as complete and easy as possible. Until next time take care and keep learning.


Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!

100% SPAM FREE! We will never sell or rent your email address!