Solved

An existing Access Database table issue

Posted on 2006-07-06
5
187 Views
Last Modified: 2010-04-23
I have an existing Access database that has
tables (around 10). A routine that will open
any of the tables and allow the user close the
table when finished is needed.
0
Comment
Question by:farrellthrasher
  • 2
5 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 17056176
Couldn't get what you want
What do you mean Close the Table ?
What would you do after opening the tabel, would you want to insert/update some data ?
0
 

Author Comment

by:farrellthrasher
ID: 17063280
What I mean is that a routine that will allow me to access an Access database with 5 to 10 tables is needed. I would like to access any of the tables and access another table when I am finished inserting, updating or deleting data.
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 17070658
OK What I get from your query is that you want to list all the tables from your database
and then let the user select a table and work on it.
If he wants he can select another table and work on it and so on...

I am showing you the code for getting the table names from the access database showing them to user and based on the user selection showing records from the selected table to the user in a grid so that he can manipulate the data

>>>
Have a Listbox (LstTables) and a DataGridView(DGV) on your form then have this function

    Private Sub LoadTables()
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0......." 'Have your Connection string here
        Dim Cn As New OleDbConnection(ConStr)
        Cn.Open()
        Dim DT As DataTable = Cn.GetSchema("Tables")
        For Each dr As DataRow In DT.Rows
            If dr("TABLE_TYPE").ToString.ToUpper = "TABLE" Then LstTables.Items.Add(dr("TABLE_NAME").ToString.TrimEnd("$"))
        Next
        Cn.Close()
    End Sub

Call this function from say your Form_Load,

Also have this function to show data in Grid

    Private Sub LoadGrid(ByVal TblName As String)
        Dim Qry As String = String.Format("Select * from {0}", TblName)
        Dim DA As New OleDbDataAdapter(Qry, ConStr)
        Dim DT As New DataTable
        DA.Fill(DT)
        DGV.DataSource = DT
    End Sub

Select tables in the Listbox and you will see data populated in the Grid
This code however does not show you how to edit/update etc. the database table, you can find abundant help on the net for Updating/Inserting data into database table from a grid.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question