Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. Im trying to make a program (vb2010) that can connect to a selected .mdb database and draw a chart based on the data in it. The idea is to be able to selct which file to open, and draw a chart based on what data is in it. Currently i am able to save the path to the db as a string, but i have problems saving the content of the db (don't know if i have to) and link it to the charts datasource. I've followed some tutorials but they dont seem to answe my question. I do not have MS Access ,so i cant drag and drop skeletons (or whatever they are called) into my code.

Can any1 plz help?

this is my database:




This is my code so far

VB
Imports System.Data.OleDb


Public Class Form1

    Dim connString As String
    Dim dbConn As OleDbConnection
    Dim dbComm As OleDbCommand
    Dim dbDataSet As DataSet
    Dim dbDataAdapter As OleDbDataAdapter
    Dim dbDataReader As OleDbDataReader
    Dim tab1 As DataTable

    Dim Item(2) As String



    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        openFD.InitialDirectory = "C:\"
        openFD.Title = "Open a .mdb database"
        openFD.Filter = ".mdb |*.mdb"
        openFD.ShowDialog()

        connString = openFD.FileName
        TextBox1.Text = connString

        ''''''''''''
        Dim Table_ As String = "Table1"
        Dim query As String = "SELECT * FROM " & Table_
        Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=connString;"
       
        dbConn = New OleDbConnection(MDBConnString_)

        dbConn.Open()
        dbComm = New OleDbCommand(query, dbConn)
        dbDataAdapter = New OleDbDataAdapter(dbComm)
        dbDataAdapter.Fill(dbDataSet, Table_)
        dbConn.Close()

        tab1 = dbDataSet.Tables(Table_)
        Dim row As DataRow

        For Each row In tab1.Rows
            Item(0) = row(0)
            Item(1) = row(1)
            Dim NextListItem As New ListViewItem(Item)



        Next


    End Sub

    Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub openFD_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles openFD.FileOk

    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Chart1.DataSource = tab1
    End Sub
End Class
Posted
Comments
Maciej Los 29-Sep-14 17:23pm    
What's the problem?

1 solution

the problem is i don't know how to store the data/or draw it in the chart. I also need to be able to zoom and do some mathematical operations on the data (mean value on certain intervals), but that is something i will look at down the road.

I'm not sure i need the dataadapter, but I'm a bit new to this. Also, the table i need acces to is one of many (in the db), And I'm not sure how to reach that specific one. For now, what i need to know is 2 things.

1
How to set up alink to any .mdb file on my computer, using oledb.

2
How to display the data in the .mdb file in a chart.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900