Solved

An existing Access Database table issue

Posted on 2006-07-06
5
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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