|
-
Jul 11th, 2006, 10:18 AM
#1
Thread Starter
Junior Member
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:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SR As StreamReader
SR = File.OpenText("C:\Documents and Settings\Owner\My Documents\Visual Studio Projects\DataImport\DataImport\ProfileList.txt")
Dim x As String
Dim y() As String
Dim i As Integer = 0
While SR.Peek <> -1
x = SR.ReadLine()
y = Split(x, ",")
ReDim Preserve DataProf(i)
DataProf(i).ID = y(0)
DataProf(i).CString = y(1)
DataProf(i).Table = y(2)
i = i + 1
End While
SR.Close()
Dim CSt As String
For i = 0 To UBound(DataProf)
CSt = DataProf(i).CString
CS = New ADODB.Connection
CS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= " & CSt
CS.Open()
'---------Here is where the code will go to populate the TBL() array with the table ID's.
Dim TBL() As String
RS = New ADODB.Recordset
'RS.Open("TBL() ARRAY GOES HERE!", CS, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic, ADODB.CommandTypeEnum.adCmdTable)
If RS.RecordCount > 0 Then RS.MoveFirst()
CS.Close()
CS = Nothing
Next
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|