Vb.Net-Informations.com

  How to create DataSet without Databse




   Categories

    HOME
    VB.NET
    CSHARP

 
   














How to create DataSet without Databse

Dataset represents a collection of data retrieved from the Data Source. The DataSet contains DataTableCollection and their DataRelationCollection. The DataTableCollection contains zero or more DataTable objects. The data set may comprise data for one or more members, corresponding to the number of rows. We can fill the data in Dataset without calling SQL statements. For that we manually create a DataTable and add data in it.


         VB.NET Source Code Download           Print Source Code
         How to create DataSet without Databse - Download
        
VB.Net Tutorial

Imports System.Data.OleDb
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim dr As DataRow
        Dim idCoulumn As DataColumn
        Dim nameCoulumn As DataColumn
        Dim i As Integer

        dt = New DataTable()
        idCoulumn = New DataColumn("ID", Type.GetType("System.Int32"))
        nameCoulumn = New DataColumn("Name", Type.GetType("System.String"))

        dt.Columns.Add(idCoulumn)
        dt.Columns.Add(nameCoulumn)

        dr = dt.NewRow()
        dr("ID") = 1
        dr("Name") = "Name1"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr("ID") = 2
        dr("Name") = "Name2"
        dt.Rows.Add(dr)

        ds.Tables.Add(dt)

        For i = 0 To ds.Tables(0).Rows.Count - 1
            MsgBox(ds.Tables(0).Rows(i).Item(0) & "   --   " & ds.Tables(0).Rows(i).Item(1))
        Next i

    End Sub
End Class


		

ADO.NET Dataset Related Contents
*     What is ADO.NET Dataset
*     How to Dataset with Sql Server
*     How to Dataset with OLEDB Data Source
*     Search Tables in a Dataset Sql Server
*     Search Tables in a Dataset OLEDB Data Source
*     Dataset table row count in SQL Server
*     Dataset table row count - OLEDB Data Source
*     How to find column definition - Sql Server
*     How to find column definition - OLEDB Data Source
*     How to multiple tables in Dataset - Sql Server
*     How to multiple tables in Dataset - OLEDB Data Source
*     How to add relations between tables in a Dataset
*     How to merge tables in a Dataset - Sql Server
*     How to merge tables in a Dataset - OLEDB Data Source

VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial with source code
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
Search here for more CSharp Source Code :

  |  Home   |  SiteMap   |  About   |
net-informations.com (C) 2010 All Rights Reserved