Vous êtes sur la page 1sur 20

Visual Basic.

NET

Creating ADO.NET code and bound forms in Data Form Wizard Visual Basic.NET

One of the advantages of using Visual Studio.NET to create data-bound applications is


that the development environment provides components and wizards to automate the
creation of data objects. The Data Form Wizard creates a complete data-bound form that
is fully functional, fetching data form a database, creating navigation buttons, allowing
you to perform inserts, edits and deletions, and saving changes back to the database.

The following steps give you how to create ADO.NET Code in Data Form Wizard

Visual Basic.NET (In this case, I use Northwind Orders and Order Details tables) :
1. Open Microsoft Visual Studio.NET, then create New Project and name it Data
Wizard.

1 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

2. Right Click on the project in Solution Explorer window and choose Add | Add
New Item.

2 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

3. Select Data Form Wizard, then click Open button.

3 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

4. After you click Open button, then will be look like this. Then click Next button.

4 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

5. Name it dsSample in “Create a new dataset named”, then click Next button.

5 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

6. Choose a data connection if you already have a data connection. If you don’t
have a data connection before, you must create it (After this, I will explain how to
creating a data connection).

6 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

Creating Data Connection

Click New Connection button to create a data connection. Select Microsoft


OLE DB Provider for SQL Server (the provider).

7 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

Enter your Server Name, then choose Use Windows NT Integrated security
and Select the database (Northwind).

8 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

After it, click Test Connection button to show that connection is right. Then
click OK button.

Now you already have a new data connection as shown in step 6.

9 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

7. Click Next button, then will be look like this :

10 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

8. Select Order Details and Orders tables by moving them to the right-arrow
button. Then click Next button.

11 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

9. Fill the Name, Parent table, Child table and Keys like steps 10.

12 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

10. Then click right-arrow button to add the relation to the Relations box on the
right side of the dialog box.

13 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

11. Click Next button.

14 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

12. Select Orders in Master or single table then click Next button.

15 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

13. Click Next button.

16 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

14. Select Single record in individual controls option, then click Finish button.

17 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

15. Now, the form designer and code has been created.

18 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

19 Hendra Gunawan Djaja property


Copyright © 2004
Visual Basic.NET

16. To test the form, set is as the startup form for the project.

Result :

Contact :
Hendra Gunawan Djaja
Email : hendragd@yahoo.com

20 Hendra Gunawan Djaja property


Copyright © 2004

Vous aimerez peut-être aussi