VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Fill Data Gridview Using Dataset

by Gehan Fernando (47 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Wed 2nd May 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Fill Data Gridview Using Dataset

API Declarations


Imports System.Data.OleDb

Rate Fill Data Gridview Using Dataset




        Try
            DGrid.DataSource = ReturnData().Tables(0)
        Catch ex As OleDbException
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

 Private Function ReturnData() As DataSet

        Try
            Dim OleCon As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB")
            OleCon.Open()
            Dim OleCom As New System.Data.OleDb.OleDbCommand("SELECT * FROM Products", OleCon)
            OleCom.CommandType = CommandType.Text
            Dim OleAdap As New System.Data.OleDb.OleDbDataAdapter(OleCom)
            Dim OleDSet As New DataSet()
            OleAdap.Fill(OleDSet)
            Return OleDSet
        Catch ex As Exception
            Throw ex
        End Try

    End Function

Download this snippet    Add to My Saved Code

Fill Data Gridview Using Dataset Comments

No comments have been posted about Fill Data Gridview Using Dataset. Why not be the first to post a comment about Fill Data Gridview Using Dataset.

Post your comment

Subject:
Message:
0/1000 characters