|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem inserting a text file into an ACCESS DB
When I insert this text file into my db I asigned the size of each field this way:
date = Trim(Mid(LineaLeida, 1, 10)) But it gives me a problem when one particular field changes its length from time to time (it doesnīt have a constant length). Iīd like a way of measuring the fieldīs length and taking as many characters as its length instead of taking some of the next fieldīs characters in order to complete its defined length, which is whatīs happening now. I know what I have to do but Iīm not sure how to do it?, maybe someone could help me out on this one. Thanks! ================================================== ================================================= This is part of my code: NumFichero = FreeFile Open Path For Input As NumFichero Do Line Input #NumFichero, LineaLeida fecha = Trim(Mid(LineaLeida, 1, 10)) hora = Trim(Mid(LineaLeida, 12, 8)) usuario = Trim(Mid(LineaLeida, 21, 12)) codigo = Trim(Mid(LineaLeida, 34, 12)) cliente = Trim(Mid(LineaLeida, 47, 7)) cuenta = Trim(Mid(LineaLeida, 55, 7)) <=====================This is the field that changes its length movil = Trim(Mid(LineaLeida, 63, 10)) ci = Trim(Mid(LineaLeida, 74, 2)) mes = Trim(Mid(LineaLeida, 77, 4)) estado = Trim(Mid(LineaLeida, 82, 31)) If fecha <> "Fecha" Then query = "INSERT INTO log (fecha, hora, usuario, codigo, cliente, cuenta, movil, ci, mes, estado) VALUES ('" & fecha & "', '" & hora & "', '" & usuario & "', '" & codigo & "', '" & cliente & "', '" & cuenta & "', '" & movil & "', '" & ci & "', '" & mes & "', '" & estado & "') " 'txtfields1.Text = query db.Execute (query) End If Loop Until EOF(NumFichero) Close NumFichero ================================================== ================================================= |
|
#2
|
|||
|
|||
|
There is a Len function in VBScript
numChar = Len(someString)
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
I tried the len function and worked like a charm.
Thanks Doug! |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Problem inserting a text file into an ACCESS DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|