954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

displaying columns from ms access table to a listview in vb.net

guys can you please help me in displaying columns from my ms access table to a listview in vb.net..

i use oledb in connecting to ms access..

cjoyce
Newbie Poster
8 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

try this:

Imports System.Data
Imports System.Data.OleDb

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim con As New OleDbConnection("Connection string")
    Dim cmd As New OleDbCommand
    Dim da As New OleDbDataAdapter

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        con.Open()
        cmd = New OleDbCommand("select * from Table1", con)
        Dim dt As New DataTable
        da.SelectCommand = cmd
        da.Fill(dt)
        ListView1.DataSource = dt      
        ListView1.DataBind()

    End Sub
kuracha
Newbie Poster
5 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

I'm not an expert but I'm pretty sure there is no DataSource property for a ListView at least not in VB2008 and framwork 3.5. I think you're going to have to loop through the datatable and add the items to the listview that way. I believe the DataGridView would work for what you want and it has a DataSource property that's very easy to implement.

Ken

Phasma
Junior Poster in Training
81 posts since Nov 2008
Reputation Points: 21
Solved Threads: 21
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: