Monday, June 18, 2012

Understanding Data Items

When using the example in the previous post, or in other ocasions, you may see three items, the "DataSet", "BindingSource" and "TableAdapter", so here's what they do:

DataSet:
   Stores data in memory when in "run time"

BindingSource:
   Has all the information regarding the connection and is responsible for the navigation as all the other records functionality.

TableAdapter:
   Gets data from the table and sends it to the application

Simple Database Connection

Connecting to a database is a process that can be very simple, depending on the need.
In this tutorial, i'll show you how to connect to a SQL Server database.

1) First Create a new Project













Name your project and choose the desired location on your hard drive, and press "OK"
immediately Visual Studio will create the solution for you;

2) Now, resize the form that will be holding the data, at your likes;

3) Drag and drop the "DataGridView" control into the form and resize it



4) Next, Select the "DataGridView" and click on the triangle on the top right of the control.

5) Select the combobox "Select Data Source"

6) Select the option "Add Project Data Source"

7) Select "Database" and click "Next"







8) Select "Dataset" and click "Next"







9) In this step "Choose your data connection", click on "New Connection"

10) A new window will be shown named "Choose Data Source"







11) Choose "Microsoft SQL Server". In here, if you don't have an SQL Server instance, then you can choose another database type.
      Press "Continue"

12) You'll be presented with a window called "Add Connection"


 - In this window, choose the "Server Name", by writting it or by choosing it from the combobox availlable items.
- Choose how you'll logon to the server. If you haven't configured your server to use passwords, use the first option "Use Windows Authentication", if not, you must supply the exact credentials in the second option.
-Select the database to which you want to connect to.
- Click on "Test Connection", and if your connection succeded, press "OK"

13) When returning to the window "Choose Your Data Connection", choose "Yes, include sensitive data in the connection string". and press "Next"

14) In the next section press "Next" to save the connection







15) In "Choose Your Database Objects", select the exact table you want to use or all the items and click "Finish" (when selecting all the items, like shown bellow, the wizzard will prompt you for the exact table to use, at the end of this process)







Now, you can just Press "F5" and run the project. If everything worked fine, you'll see you data listed on the form.

Friday, March 23, 2012

Visual Basic

Hi everyone

I start this blog as a way to help Visual Basic developers to find solutions to their problems on their day-to-day tasks.As we all know, when having dificulties on a certain task, its a lot easier to find the solution on the internet than to keep hitting the head against the wall, killing brain cells.
They might be usefull for another time, when no one knows the sollution to the
problem.
This blog relates to all version of Visual Basic. So when posting i'll reference the Visual Basic version i'm refering to.

I hope to help you all, but you can also help others, by posting
comments on this blog.

Please, take note that every case presented here may work in some cases and not work in other cases. You should allways be aware of what you're doing and what consequencies the solutions presented here might have on your sistem (software and/or hardware). Although my intentions are only of helping others, not to harm anyone, you should understand that it's impossible to find solutions that work for everyone and ensure that those sollutions won't harm the system for some reason.

Enjoy and take advantage