Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. DataGridView Help... Manual Loading of ACCESS Records into DataGridView

DataGridView Help... Manual Loading of ACCESS Records into DataGridView

Scheduled Pinned Locked Moved Visual Basic
helpdatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vbDiggerz
    wrote on last edited by
    #1

    DataGridView Help... Manual Loading of ACCESS Records into DataGridView I have read such an article and code about mannual loading of records from database into datagridview not by means of "DataReader and FOR LOOP" looping process to each rows and cells to put each corresponding value.. instead? he just use an OleDataAdapter to fill a DataTable and set the "DatagridView.AutoGenerateColumns = false" then he set DataGridView.DataSource = DataTable that he made.. for him it works.. but for me i dont know what's lacking in my code.. there's no error occur but the records doesn't display inside my pre-defined column inside my datagridview.. instead? it just generate a blank row with the same rowCount of my table inside my database.. but when i set my DataGridView.AutoGenerateComlumn = true? then it display on system way.. but not in the way i wanted it to be display inside my custom column inside the datagridview.... here's my sample code... ************ Dim oleDataAdapter1 As OleDbDataAdapter Dim OleCommandBuilder1 As OleDbCommandBuilder Dim dbDataSet As New DataSet() Dim tempDataTable As DataTable = dbDataSet.Tables.Add("tempTable") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try oleConnection.ConnectionString = dbConnectionString oleConnection.Open() oleCommand = New OleDbCommand("Select * From tempTable", oleConnection) oleDataAdapter1 = New OleDbDataAdapter(oleCommand) OleCommandBuilder1 = New OleDbCommandBuilder(oleDataAdapter1) oleDataAdapter1.Fill(tempDataTable) With DataGridView1 .AutoGenerateColumns = False .DataSource = tempDataTable End With Catch ex As Exception MsgBox(ex.ToString()) Finally oleCommand.Connection.Close() End Try End Sub ************** Note: I have 4 column created inside the datagridview.. columnName(ID,NAME,DATE,AGE) dataType(string,string,date,number) I know.. you can laugh at me.. just can't figured it out.. ehehe... please help... Please anyone there who has much deeper experience and knowledge in vb programming who can help me with this??? please.. a lot of appreciation in advance... please...

    D 1 Reply Last reply
    0
    • V vbDiggerz

      DataGridView Help... Manual Loading of ACCESS Records into DataGridView I have read such an article and code about mannual loading of records from database into datagridview not by means of "DataReader and FOR LOOP" looping process to each rows and cells to put each corresponding value.. instead? he just use an OleDataAdapter to fill a DataTable and set the "DatagridView.AutoGenerateColumns = false" then he set DataGridView.DataSource = DataTable that he made.. for him it works.. but for me i dont know what's lacking in my code.. there's no error occur but the records doesn't display inside my pre-defined column inside my datagridview.. instead? it just generate a blank row with the same rowCount of my table inside my database.. but when i set my DataGridView.AutoGenerateComlumn = true? then it display on system way.. but not in the way i wanted it to be display inside my custom column inside the datagridview.... here's my sample code... ************ Dim oleDataAdapter1 As OleDbDataAdapter Dim OleCommandBuilder1 As OleDbCommandBuilder Dim dbDataSet As New DataSet() Dim tempDataTable As DataTable = dbDataSet.Tables.Add("tempTable") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try oleConnection.ConnectionString = dbConnectionString oleConnection.Open() oleCommand = New OleDbCommand("Select * From tempTable", oleConnection) oleDataAdapter1 = New OleDbDataAdapter(oleCommand) OleCommandBuilder1 = New OleDbCommandBuilder(oleDataAdapter1) oleDataAdapter1.Fill(tempDataTable) With DataGridView1 .AutoGenerateColumns = False .DataSource = tempDataTable End With Catch ex As Exception MsgBox(ex.ToString()) Finally oleCommand.Connection.Close() End Try End Sub ************** Note: I have 4 column created inside the datagridview.. columnName(ID,NAME,DATE,AGE) dataType(string,string,date,number) I know.. you can laugh at me.. just can't figured it out.. ehehe... please help... Please anyone there who has much deeper experience and knowledge in vb programming who can help me with this??? please.. a lot of appreciation in advance... please...

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      What does the column generation code look like?? You're probably missing setting the DataPropertyName for each column. This tells the column which column in the DataSource to bind to.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups