Group Discounts available for 3+ students and Corporate Clients

Working with typed Dataset in vb.net

Working with typed Dataset:

Typed Dataset:

Whenever a Dataset is defined based on the XML schema definition file then it is said to be typed dataset.

To create a Typed Dataset

Go to project [menu] UntitledAdd new item Untitled Under installed Templates [left menu] Untitled select data Untitled select Dataset [middle menu]

Name: NorthWindDs.Xsd

Click Add

Click on server Explorer

Rclick on Data Connections à click on add connections

Choose Data Source

Data Source

[Microsoft Account Database fib

Microsoft SQL Server — ]select this

Continue Untitled click

Then window will be opened.

Server name “sekhar” — differs from system to system

Check Radio button use SQL server authentication

Username: Sa

Password: 123 (***)

Check      save my password

Select or enter a database name

Select NorthWind in drop down list

Click on [Test Connection]

Test connection successful          [OK]

The above steps address a new Data Connection to server Explorer.

Under Tables in Server Explorer

Select Employees tables and drag and drop the table on form

A Message box is displayed to save password click yes

Save ctrl + s

Project [menu] Untitled Add Windows Forms

Click on Data [menu] à Show Data Sources

We will get a list of NorthWind DS – Employees

Select Employees and drag and drop on the form.

Select Dock property = till

Execute

Then we get a Table

If the client wants table in the form of navigation then ?

 

Projecting the Data using Navigation style:

Project [menu] Untitled Add Windows Form

Click on Data [menu] à Show Data Sources

We get Untitled NorthWind DC

Employees

Expand this employees

(-) Employee Id

(-)  Last Name

(-) First Name

 

Drag and drop the columns available under Employees individually on to the form like (sample)

 

Screenshot_55

Navigation style is achieved Screenshot_56

 

Establishing Data Relations using Typed Data Set:

Open NorthWindDs.Xsd

Open ServerExplorer

Drag and drop categories and products

Tables on to NorthWindDs.Xsd

If any relation exists if relates among tables.

Save Untitled ctrl + s

Go to project [menu] UntitledAdd Windows Form

Click on Data [menu] Untitled Show Data Sources

In Data Source list table we get categories, products tables

Expand categories table

Drag and drop required columns from the categories table on to the form (like)

 

Screenshot_57

 

Working with Tree View control:

Let us design a sample like this

Screenshot_58

 

 

Working with Tree View control:

Let us design a sample like this

 

Screenshot_59

 

Take a new WINFORM

Drag & drop Tree View control

Set Dock = left

Drag & drop splitter control

Drag & drop Group box on form (Rside)

Resize Group box

Drag & drop 4 labels, 4 text boxes, and button in Group box

Select text for Group box as project Details

(Form6_Load)

Above Imports System.Data

Imports System.Data.SqlClient

‘Form Declarations

Dim cn as SqlConnection

Dim cn as SqlCommand

Dim da as SqlDataAdapter

Dim ds as DataSet

Dim dr as SqlDataReader

For Form_Load

Cn = New SqlConnection (“user id = sa; password = 123; database = northwind; data source = sekhar”)

da = New SqlDataAdapter (“Select * from categories”, cn)

ds = New DataSet

da.Fill (ds, “Products”)

cmd = New Sql Command (“Select * from categories”, cn)

if cn.State = ConnectionState closed then

cn.Open ()

End if

dr = cmd.Executereader

Dim root as New TreeNode

Root Text = “Available Products”

While dr.Read

Executes the loop till records are present in Data Reader

Dim Parent as new Tree Node

Parent.text = dr.GetValue (1)

For r as integer = 0 to ds.Tables (“Products”).Rows.Count -1

If dr.GetValue (0) = ds.Tables (“Products”)

Rows (r) (“CategoryId”) Then

Dim child as New treeNode

Child.text = ds.Tables (“Products”. Rows (r) (“Product Name”)

Child.Tag = ds.Tables (“products”).Rows (r) (“Product Id”)

Parents.Nodes.Add (Child)

End if

Next

Root Nodes.Add (parent)

End while

TreeView l.Nodes.Add (root)

ds.Tables (“Products”).Constrints.Add (“Pid_Pk”,

ds.tables (“Product”).Columns (“Product Id”), True)

 

Double click on Tree View Control:

‘TreeView1_After Select

If e.Node.Text <> “Available Products” Then

If e.Node.ParentText <> “Available Products” Then

Dim row as DataRow

Row = ds.Tables (“Products”).Rows.Find (e.Node.Tag)

txtProductId.Text = row (“Product Id’)

txtProductName.Text = row (“Product Name”)

txtQuantity.Text = row (“Quantity per Unit’)

txtPrice.Text = row (“Unit Price’)

End if

End if

Untitled Execute

Assign

DeptEmp
Dept noEno
DnameEname
LocEsal
Job
Dept no

 

 

 

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Working with typed Dataset in vb.net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please Enter Your Details and Query.
    Three + 6