Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 10th, 2005, 04:44 PM
msevilla msevilla is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 14 msevilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 52 sec
Reputation Power: 0
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

================================================== =================================================

Reply With Quote
  #2  
Old January 11th, 2005, 12:59 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 22 h 33 m
Reputation Power: 181
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

Reply With Quote
  #3  
Old January 11th, 2005, 10:50 AM
msevilla msevilla is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 14 msevilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 52 sec
Reputation Power: 0
I tried the len function and worked like a charm.
Thanks Doug!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Problem inserting a text file into an ACCESS DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT