Jeremy Toves
itsame2000 at sbcglobal.net
Mon Sep 19 14:09:02 CDT 2005
I've worked with DAO for so long, I'm finally taking the plunge into ADO. I have a database that pulls up records I need from an Oracle database. No issues there. What I want to do now is make a dynamic output table to push all my results to. I may be going about this the wrong way. Does anybody have suggestions?
Thanks,
Jeremy Toves
*************************************
Sub PullRecords()
Dim rs As Recordset
Dim cn As Connection
Dim strCn As String, strSQL As String
Dim intX As Integer, intFieldCnt As Integer
strCn = "ODBC; " _
& "Provider=MSDASQL.1; " _
& "Driver=Oracle ODBC Driver; " _
& "DBQ=tns_name; " _
& "UID=username; " _
& "PWD=password;"
strSQL = "SELECT " _
& "TableName.* " _
& "FROM " _
& "TableName " _
& "WHERE " _
& "TableName.Fieldname Like " & Chr(39) & "1234%" & Chr(39) & ";"
Set cn = New Connection
cn.ConnectionString = strCn
cn.Open
Debug.Print cn.ConnectionString
Set rs = cn.Execute(strSQL)
intFieldCnt = rs.Fields.Count
For intX = 0 To intFieldCnt - 1
Debug.Print rs.Fields(intX).Name & ": " & rs(intX)
========>> I want to create a table based on the columns I pull here. I'd like it to be dynamic allowing me to reuse the same process to output the result of different source tables. Ideas? <<========
Next
rs.Close
cn.Close
End Sub