Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. import a text file sorting a list of values

import a text file sorting a list of values

Scheduled Pinned Locked Moved Database
databasealgorithmsdata-structuresquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chris foote
    wrote on last edited by
    #1

    I have a recodset that has been impoted from a csv text file. This is done via reading each line if the csv/text file into a sting procing the sting into an array and then add the values to the recordset. So I end up with a nice recordset. Now I seem unable to sort the recordset so that it contins a list of distint names. (EG I want a list of of the printers in the recordset). normanly this can be done via sql with the command "select distinctrow field list from tablename" however as i've populated the recordset from a text file i do not know what the tablename is? can anyone tell me how this is done or suggest another way? I'm programing this in vb6.0. thank you

    M B 2 Replies Last reply
    0
    • C chris foote

      I have a recodset that has been impoted from a csv text file. This is done via reading each line if the csv/text file into a sting procing the sting into an array and then add the values to the recordset. So I end up with a nice recordset. Now I seem unable to sort the recordset so that it contins a list of distint names. (EG I want a list of of the printers in the recordset). normanly this can be done via sql with the command "select distinctrow field list from tablename" however as i've populated the recordset from a text file i do not know what the tablename is? can anyone tell me how this is done or suggest another way? I'm programing this in vb6.0. thank you

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      You didn't mention if you use SQLServer,access or vf so How did you import them?(programmically)As I remember,when SQLServer import database you can define table name. Can't you set name manually if you use Access or SQLServer or..? Mazy Don't Marry a Person You Can Live With... Marry Someone You Can Not Live Without

      C 1 Reply Last reply
      0
      • M Mazdak

        You didn't mention if you use SQLServer,access or vf so How did you import them?(programmically)As I remember,when SQLServer import database you can define table name. Can't you set name manually if you use Access or SQLServer or..? Mazy Don't Marry a Person You Can Live With... Marry Someone You Can Not Live Without

        C Offline
        C Offline
        chris foote
        wrote on last edited by
        #3

        Thanks for responding, I am not connecting to any SQL server. I am just opening a text file and populating a recordset My code is below. After I run this I am having trouble finding a way to just get a list of unique QueueName's from the recordset?? I create a recordset via this code.... Set rs = New Recordset rs.CursorLocation = adUseClient rs.Fields.Append "UserName", adBSTR, 128 rs.Fields.Append "DocName", adBSTR, 128 rs.Fields.Append "QueueName", adBSTR, 128 rs.Fields.Append "Date", adDBDate rs.Fields.Append "Time", adDBTimeStamp rs.Fields.Append "Workstation", adBSTR, 128 rs.Fields.Append "ClientCode", adBSTR, 128 rs.Fields.Append "Subcode", adBSTR, 128 rs.Fields.Append "PaperSize", adBSTR, 128 rs.Fields.Append "Features", adBSTR, 128 rs.Fields.Append "Sizeinbytes", adBSTR, 128 rs.Fields.Append "Pagecount", adBSTR, 128 rs.Fields.Append "cost", adBSTR, 128 rs.Fields.Append "AccountBalance", adBSTR, 128 rs.Open Then I import the txt file into the recordset using this code... Dim F As Long, sLine As String, A(0 To 13) As String F = FreeFile Open "C:\temp\text.txt" For Input As F Do While Not EOF(F) Line Input #F, sLine ParseToArray sLine, A() rs.AddNew rs.Fields(0) = A(0) rs.Fields(1) = A(1) rs.Fields(2) = A(2) rs.Fields(3) = CDate(A(3)) rs.Fields(4) = CDate(A(4)) rs.Fields(5) = A(5) rs.Fields(6) = A(6) rs.Fields(7) = A(7) rs.Fields(8) = A(8) rs.Fields(9) = A(9) rs.Fields(10) = A(10) rs.Fields(11) = A(11) rs.Fields(12) = A(12) rs.Fields(13) = A(13) rs.Update DoEvents Loop Close #F End Sub Sub ParseToArray(sLine As String, A() As String) Dim P As Long, LastPos As Long, i As Long P = InStr(sLine, ",") Do While P A(i) = Mid$(sLine, LastPos + 1, P - LastPos - 1) LastPos = P i = i + 1 P = InStr(LastPos + 1, sLine, ",", vbBinaryCompare) Loop A(i) = Mid$(sLine, LastPos + 1) End Sub

        M 1 Reply Last reply
        0
        • C chris foote

          Thanks for responding, I am not connecting to any SQL server. I am just opening a text file and populating a recordset My code is below. After I run this I am having trouble finding a way to just get a list of unique QueueName's from the recordset?? I create a recordset via this code.... Set rs = New Recordset rs.CursorLocation = adUseClient rs.Fields.Append "UserName", adBSTR, 128 rs.Fields.Append "DocName", adBSTR, 128 rs.Fields.Append "QueueName", adBSTR, 128 rs.Fields.Append "Date", adDBDate rs.Fields.Append "Time", adDBTimeStamp rs.Fields.Append "Workstation", adBSTR, 128 rs.Fields.Append "ClientCode", adBSTR, 128 rs.Fields.Append "Subcode", adBSTR, 128 rs.Fields.Append "PaperSize", adBSTR, 128 rs.Fields.Append "Features", adBSTR, 128 rs.Fields.Append "Sizeinbytes", adBSTR, 128 rs.Fields.Append "Pagecount", adBSTR, 128 rs.Fields.Append "cost", adBSTR, 128 rs.Fields.Append "AccountBalance", adBSTR, 128 rs.Open Then I import the txt file into the recordset using this code... Dim F As Long, sLine As String, A(0 To 13) As String F = FreeFile Open "C:\temp\text.txt" For Input As F Do While Not EOF(F) Line Input #F, sLine ParseToArray sLine, A() rs.AddNew rs.Fields(0) = A(0) rs.Fields(1) = A(1) rs.Fields(2) = A(2) rs.Fields(3) = CDate(A(3)) rs.Fields(4) = CDate(A(4)) rs.Fields(5) = A(5) rs.Fields(6) = A(6) rs.Fields(7) = A(7) rs.Fields(8) = A(8) rs.Fields(9) = A(9) rs.Fields(10) = A(10) rs.Fields(11) = A(11) rs.Fields(12) = A(12) rs.Fields(13) = A(13) rs.Update DoEvents Loop Close #F End Sub Sub ParseToArray(sLine As String, A() As String) Dim P As Long, LastPos As Long, i As Long P = InStr(sLine, ",") Do While P A(i) = Mid$(sLine, LastPos + 1, P - LastPos - 1) LastPos = P i = i + 1 P = InStr(LastPos + 1, sLine, ",", vbBinaryCompare) Loop A(i) = Mid$(sLine, LastPos + 1) End Sub

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          Sorry to disappointed you,I can't understand these code because I don't know VB:-O Mazy Don't Marry a Person You Can Live With... Marry Someone You Can Not Live Without

          1 Reply Last reply
          0
          • C chris foote

            I have a recodset that has been impoted from a csv text file. This is done via reading each line if the csv/text file into a sting procing the sting into an array and then add the values to the recordset. So I end up with a nice recordset. Now I seem unable to sort the recordset so that it contins a list of distint names. (EG I want a list of of the printers in the recordset). normanly this can be done via sql with the command "select distinctrow field list from tablename" however as i've populated the recordset from a text file i do not know what the tablename is? can anyone tell me how this is done or suggest another way? I'm programing this in vb6.0. thank you

            B Offline
            B Offline
            Bill Wilson
            wrote on last edited by
            #5

            This may be disloyal, but look on the code guru site. It contains several examples of FTP code. http://codeguru.com/internet/index.shtml Hope this helps, Bill

            B 1 Reply Last reply
            0
            • B Bill Wilson

              This may be disloyal, but look on the code guru site. It contains several examples of FTP code. http://codeguru.com/internet/index.shtml Hope this helps, Bill

              B Offline
              B Offline
              Bill Wilson
              wrote on last edited by
              #6

              Please disregard the previous post, I typed it into the wrong window. It has nothing to do with this question. Thanks for the help, Bill

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups