LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ODBC query excluding headers

Hi,

Can someone tell me how to exclude the header or titles from the
results of an ODBC query against a MySQL DB.

Here is my code in case someone else would like to use it.

Sub get_oem_data(RowIndex, LastRowOfData, Program)

Dim oemConn As String
Dim oemSql As String
Dim oQt As QueryTable
Dim start_row As Integer

Application.StatusBar = "Clean out old OEM Data"
Sheets("oem_data").Select
current_sheet = ActiveSheet.Name
'LastRealCell_ftr =
RealLastCell(Sheets("Insp_data")).Address(RowAbsol ute:=False,
ColumnAbsolute:=False)
'Range("A1", LastRealCell_ftr).Select
'Range("A1", "IV6536").Select
Columns("A:IV").Select
Selection.ClearContents
'Selection.Delete Shift:=xlShiftToLeft
Cells.Select
Range("IV1").Activate
Selection.Clear


oemConn = "ODBC;DATABASE=databaseName;DESCRIPTION=MySQL ODBC 3.51
Drive
DSN;DSN=DSNConnectionName;OPTION=0;;PORT=0;SERVER= server.com;UID=userlogin"

Sheets("variables").Select

oemSql = "SELECT * "

oemSql = oemSql & "FROM aces_data.oem_data_fpm oem_data_fpm_0 "

oemSql = oemSql & "WHERE 1 AND ( ( "

If (RowIndex < start_row) Then

oemSql = oemSql & " OR ( "
End If

If (Cells(RowIndex, "C").Value < "") Then
oemSql = oemSql & " AND oem_data_fpm_0.Program=" & "'"
oemSql = oemSql & Cells(RowIndex, "C") & "'"
End If

oemSql = oemSql & " ) "


oemSql = oemSql & " ) "

oemSql = oemSql & " ORDER BY oem_data_fpm_0.id "
'MsgBox oemSql
Sheets("oem_data").Select
Cells(LastRowOfData, "A").Value = oemSql

If (LastRowOfData < 1) Then
LastRowOfData = LastRowOfData + 1
End If
insert_here_cell = "A" & LastRowOfData
Set oQt = ActiveSheet.QueryTables.Add( _
Connection:=oemConn, _
Destination:=Range(insert_here_cell), _
Sql:=oemSql)

oQt.Refresh BackgroundQuery:=False ' explicitly set background off
Call move_oem_data_to_tcgaz_sheet
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC Query Laddie Excel Worksheet Functions 0 April 23rd 10 03:35 PM
excluding column headers from formulas yowzers Excel Worksheet Functions 3 December 15th 09 07:42 PM
How can I not overwrite my column headers when I do an ODBC refres Glen Excel Discussion (Misc queries) 2 April 2nd 09 03:43 PM
Problem with .Background Query option of ODBC Query Shilps Excel Programming 0 April 19th 04 06:41 AM
SQL query to ODBC gkelle[_5_] Excel Programming 2 February 12th 04 01:34 PM


All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"