HI!
I have a problem with getting data from Access database in VB. I have database file with 10 files and program which gets data from each database table and writes them into listbox. Now here is the problem: program gets column from table, that's planned, but it doesn't gets values for each row. it just writes for each row the same: "system.data.oledb.oledbdatareader". So.. how would i get values from table?
Here is the code:
PS: Sorry for my english
I have a problem with getting data from Access database in VB. I have database file with 10 files and program which gets data from each database table and writes them into listbox. Now here is the problem: program gets column from table, that's planned, but it doesn't gets values for each row. it just writes for each row the same: "system.data.oledb.oledbdatareader". So.. how would i get values from table?
Here is the code:
Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms Public Class Main_Menu Inherits System.Windows.Forms.Form Dim PwdCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "/ekratkočasnik.accdb;" 'Persist Security Info=False;" if your DB is not PWD protected Dim oledbcon As New OleDbConnection(PwdCon) Private Sub IgreZaMalčkeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IgreZaMalčkeToolStripMenuItem.Click StatusLabel.Text = "Izbrana kategorija: IGRE ZA MALČKE" Try oledbcon.Open() 'If oledbcon.State = ConnectionState.Open Then ' MessageBox.Show("opened") 'End If Dim strSQL As String = "SELECT IME FROM Igre_za_Malčke" Dim cmd As OleDbCommand = New OleDbCommand(strSQL, oledbcon) Dim objread As OleDbDataReader objread = cmd.ExecuteReader While objread.Read Me.ListBox_IME.Items.Add(objread.ToString()) End While objread.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally oledbcon.Close() 'If oledbcon.State = ConnectionState.Closed Then ' MessageBox.Show("closed") 'End If Me.ListBox_IME.SelectedIndex = 0 End Try End Sub
PS: Sorry for my english
Last edited by a moderator: