Results 1 to 13 of 13

Thread: Looping through Unknown Tables.

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Looping through Unknown Tables.

    Good Evening everyone.

    I'm really not sure if this is a stupid question or not, but I have searched and searched, but cannot find any "Lamens" ways of accomplishing this task.

    I have been ordered by the powers to be, again, to give up my valuable private time, and again, learn how to and carry out the creation of a piece of software that will link to a database, list the tables in that particular database, and assign various information to various variables, to create degrees of confusion. *Whew*

    ***ken boss. Sorry, just had to get it off my chest.

    Anyway, now thats out of the way, this is what I'm trying ever so hard to acheive.

    I am using ActiveX Dataobjects 2.5

    I have a textbox, inputed with a location and database file name, creatind the connection string.

    I click a button, it connects to the desired database.
    Below this textbox, I would like to list all the TABLES within that database, creating the second step.

    I'm just not sure how to retrieve the "unknown" table identities.

    These will be required for the third step to create a recordset, for each of those tables, so the user can move and select data at his/her whim.

    Ignore the "StreamReader" Related stuff, and assume this is coded in VB6.
    VB Code:
    1. Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.  
    3.         Dim SR As StreamReader
    4.         SR = File.OpenText("C:\Documents and Settings\Owner\My Documents\Visual Studio Projects\DataImport\DataImport\ProfileList.txt")
    5.         Dim x As String
    6.         Dim y() As String
    7.         Dim i As Integer = 0
    8.  
    9.         While SR.Peek <> -1
    10.             x = SR.ReadLine()
    11.             y = Split(x, ",")
    12.  
    13.             ReDim Preserve DataProf(i)
    14.             DataProf(i).ID = y(0)
    15.             DataProf(i).CString = y(1)
    16.             DataProf(i).Table = y(2)
    17.             i = i + 1
    18.         End While
    19.         SR.Close()
    20.  
    21.         Dim CSt As String
    22.         For i = 0 To UBound(DataProf)
    23.             CSt = DataProf(i).CString
    24.             CS = New ADODB.Connection
    25.             CS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= " & CSt
    26.             CS.Open()
    27.  
    28. '---------Here is where the code will go to populate the TBL() array with the table ID's.
    29.             Dim TBL() As String
    30.  
    31.             RS = New ADODB.Recordset
    32.             'RS.Open("TBL() ARRAY GOES HERE!", CS, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic, ADODB.CommandTypeEnum.adCmdTable)
    33.             If RS.RecordCount > 0 Then RS.MoveFirst()
    34.  
    35.  
    36.  
    37.             CS.Close()
    38.             CS = Nothing
    39.         Next
    40.  
    41.  
    42.  
    43.     End Sub


    Does anybody know a relatively simple way of retrieving the table names within the database???

    Thankyou so much in advance.

    -Honki.
    Last edited by honki; Jul 11th, 2006 at 10:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width