Try this Sub Get_Vessel_Schedule()
Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim strSql As String Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open ( _ "User ID=User" & _ ";Password=Pass" & _ ";Data Source=My DB" & _ ";Provider=MSDAORA.1") strSql = "" strSql = strSql & vbLf & "select VESSEL.CODE, VESSEL.NAME, VV_VESSEL_VISIT.VESSEL_ID, VV_VESSEL_VISIT.ARR_VOYAGE," strSql = strSql & vbLf & "VV_VESSEL_VISIT.DEP_VOYAGE, VV_VESSEL_VISIT.BERTH, VV_VESSEL_VISIT.MPH," strSql = strSql & vbLf & "VV_VESSEL_VISIT.ESC_FORWARD_DRAFT, VV_VESSEL_VISIT.ATA, VV_VESSEL_VISIT.ATD," strSql = strSql & vbLf & "VV_VESSEL_VISIT.ETA, VV_VESSEL_VISIT.ETD from VV_VESSEL_VISIT" strSql = strSql & vbLf & "join" strSql = strSql & vbLf & "VESSEL on VV_VESSEL_VISIT.VESSEL_ID=VESSEL.ID" rs.Open strSql, cn Cells(6, 6).CopyFromRecordset rs End Sub Regards, Lalit Mohan On Sat, Jun 23, 2012 at 5:44 AM, TJ <tj.ruc...@gmail.com> wrote: > Hello, > > Super new to thsi world but trying to put something together that will > execute a simple SQL statement against on of our Oracle Databases and return > the results. The Code for the Macro is below but I am getting "Data Type is > not Supported". Anyone help with that. Also, another question which may be > simple sytax I do nto know, what is a good mechanism to break out the SQL > statments accross various lines instead of one line? > > BTW, using Excel 2010. > > Thanks In Advance. > > > Sub Get_Vessel_Schedule() > > Dim cn As ADODB.Connection > Dim rs As ADODB.Recordset > > Set cn = New ADODB.Connection > Set rs = New ADODB.Recordset > > cn.Open ( _ > "User ID=User" & _ > ";Password=Pass" & _ > ";Data Source=My DB" & _ > ";Provider=MSDAORA.1") > > rs.Open "select VESSEL.CODE, VESSEL.NAME, VV_VESSEL_VISIT.VESSEL_ID, > VV_VESSEL_VISIT.ARR_VOYAGE, VV_VESSEL_VISIT.DEP_VOYAGE, > VV_VESSEL_VISIT.BERTH, VV_VESSEL_VISIT.MPH, > VV_VESSEL_VISIT.ESC_FORWARD_DRAFT, VV_VESSEL_VISIT.ATA, VV_VESSEL_VISIT.ATD, > VV_VESSEL_VISIT.ETA, VV_VESSEL_VISIT.ETD from VV_VESSEL_VISIT join VESSEL on > VV_VESSEL_VISIT.VESSEL_ID=VESSEL.ID", cn > > > Cells(6, 6).CopyFromRecordset rs > > End Sub > > > > -- > -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, > accurate thread titles. Poor thread titles, like Please Help, Urgent, Need > Help, Formula Problem, Code Problem, and Need Advice will not get quick > attention or may not be answered. 2) Don't post a question in the thread of > another member. 3) Don't post questions regarding breaking or bypassing any > security measure. 4) Acknowledge the responses you receive, good or bad. 5) > Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. NOTE : Don't ever post personal or confidential > data in a workbook. Forum owners and members are not responsible for any > loss. > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com To > unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com -- -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com