Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    29

    Unanswered: How to select from Excel without any header info using ADO

    I am trying to select everything from a Excel sheet Select * FROM [HELLO$]
    the fiel does not have any header information. How do I select the column without a header? How to select the column into the recordset?

    Example:
    Select * FROM [HELLO$]
    commandXLS.Execute()
    'Set recordset = commandXLS.Execute()

    recordset.MoveFirst
    Do While recordset.BOF = False And recordset.EOF = False
    'call sub to reset vars

    OrderNo = Trim(recordset.fields(?????????????))& ""


    'msgbox orderno

  2. #2
    Join Date
    Mar 2004
    Posts
    29
    Thanks anyways I got it I used the following

    sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source='"& dbPath &"';" & _
    "Extended Properties=""Excel 8.0;HDR=No;"";"

    Set commandXLS = WScript.CreateObject("ADODB.Command")
    commandXLS.ActiveConnection = sConnectionString

    'Look into the UPSCAN fil&
    commandXLS.CommandText = "SELECT * FROM [UPSCAN$] "

    Set recordset = commandXLS.Execute()

    if recordset.EOF Or recordset.BOF Then
    MsgBox "No records found!"
    WScript.Quit
    End if

    recordset.MoveFirst
    Do While recordset.BOF = False And recordset.EOF = False

    OrderNo = Trim(recordset.fields("F1"))& ""

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I think you can just use the ordinal of the field
    recordset.fields(1)
    I can't remember if that collection starts at 0 or 1, though.

    I wouldn't use "recordset" as a variable name. It's a keyword. Could lead to some confusion.
    Inspiration Through Fermentation

  4. #4
    Join Date
    Mar 2004
    Posts
    29
    Thank you1

Posting Permissions

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