import a text file sorting a list of values
-
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
-
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
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
-
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
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
-
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
-
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
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
-
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
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