Results 1 to 9 of 9

Thread: Record Set

  1. #1
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6

    Question Unanswered: Record Set

    Hi All,

    I have this big problem with Record Sets:
    I am reading a text file and recording its info in a record set.
    The text file is something like that:
    000120000, 1253, op
    000324090, 6666, op

    When reading thr record set (rs), i have this:
    rs(0) = "120000"
    rs(1) = "1253"
    rs(2) = "op"

    It reads only what is after the 1, there are three zeros not present.

    Please someone HELP!!

    Thanks in advance.


  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The zeroes are not present because the recordset as assuming the data type is numeric (integer, decimal, float etc).

    What would happen if you read rs(0).Type - what do you see?

    I believe .Type is the attribute you want anyhow!
    George
    Home | Blog

  3. #3
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6
    Hi, Thanks for replying.
    Is there any way to change the type of all the record set?
    Thanks.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Pseudo code for you to try.
    Code:
    Dim gvTest As <datatype>
    ...
    open rs
    ...
    gvTest = rs(0)
    ...
    MsgBox gvTest
    Let me know how you get on.
    George
    Home | Blog

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    do a search for schema.ini at microsoft.

    The schema.ini file is used to define the schema of a text file(s) for the text file driver.


    Here's an example schema.ini file for an ansi, pipe (|) delimited text file, without a header row.

    Code:
    [data.txt]
    Format=Delimited(|)
    CharacterSet=ANSI
    ColNameHeader=False
    Col1=Plant_Code text
    Col2=Part_Number text
    Col3=Part_Description text
    Col4=System_Lead_Time long
    Col5=Lead_Time long
    Col6=Operation_Number text
    Col7=Operation_Description text
    Col8=Operation_Type text
    Col9=Operation_Dept_Code text
    Col10=Planned_Time double
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  6. #6
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6
    Hi All,

    Thanks for replying.
    I tried all the things that could have been tried but still no solution.
    I am now trying to read all the text file and write into another temp file.
    While reading i am converting all data to string.
    And then i read temp and re-insert it in the original file.
    I will get back to you folks with the results.

    It seems that it is working but still have to test it.

  7. #7
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    In your case, the schema.ini would look something like
    Code:
    [YourFileName.csv]
    Format=CSVDelimited
    CharacterSet=ANSI
    ColNameHeader=False
    Col1=Column1_Name text
    Col2=Column2_Name text
    Col3=Column3_Name text
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  8. #8
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6

    Red face Help

    Hi all,
    I tried the way i proposed, but didn't work.
    As for schema.ini file, it doesn't apply to my case because i have a variable number of columns, and each line isn't like the other.
    Please HELP!!!!! SOS!!!!!


  9. #9
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by micheldib
    As for schema.ini file, it doesn't apply to my case because i have a variable number of columns, and each line isn't like the other.
    If each line is different, you'll have to read the file, one line at a time, and process each line individually...

    And, you'll have to expressly ensure that the target table has the correct field definitions. (Text/Varchar fields for 'numbers' which will (or might) contain leading zeros.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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