Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


bad record length error


bad record length error

Author
Message
digitman
digitman
Forum God
Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)

Group: Forum Members
Posts: 48, Visits: 1

I'm doing random file I/O in my program.But I've been repeatedly getting the Bad record length error when trying to output records whose length is around 852 characters.What should I do?


DigiRev
DigiRev
Forum God
Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)

Group: Forum Members
Posts: 511, Visits: 265

Are you using:

Open File For Binary Access Write As?

If so, how are you using the Put statement? Like this?:

Put #1, 12, Data

If that's the case, then you're probably getting an error where the number 12 is. 12, in this example, is the number of bytes, or the "offset" to place the data. So, it would seek 12 bytes into the file, and place the data after that. However, if there are not 12 bytes in the file then you will get the "Bad Record Length" error.


digitman
digitman
Forum God
Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)

Group: Forum Members
Posts: 48, Visits: 1

here's what I'm usin:

Open fpath For Random As #ff Len = Len(rot) 'ff=freefile
Put #ff, rec, rot
Close #ff


digitman
digitman
Forum God
Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)

Group: Forum Members
Posts: 48, Visits: 1
Can you please be a bit more quick since I'm really short on time
pso
pso
Forum God
Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)Forum God (72K reputation)

Group: Forum Members
Posts: 794, Visits: 338
dim RecordNumber as integer
dim trip as Keys

' (random mode example)
Open "triplog.txt" For Random As #1 Len = Len(trip)<- sometimes easy to forget which goes here
...............





Tongue

DigiRev
DigiRev
Forum God
Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)Forum God (23K reputation)

Group: Forum Members
Posts: 511, Visits: 265

Try:

Open File For Random As #1
Put #1, FileLen(File) + 1, Data
Close #1

digitman
digitman
Forum God
Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)

Group: Forum Members
Posts: 48, Visits: 1
didnt work
digitman
digitman
Forum God
Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)Forum God (6.8K reputation)

Group: Forum Members
Posts: 48, Visits: 1

may be there is a restriction on the maximum length of a record that you could output to a file,and my records exceed that limit.Anyway,what should I do?Look into binary file access?please note that we're dealing with a database program here.

thanks


brainfry
brainfry
Forum God
Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)

Group: Forum Members
Posts: 59, Visits: 4

I work with random access files all of the time. Try this;

 

if adding record to end of file:

open "filename" for random as 1 len = 852

L = lof(1) / 852 + 1

put#1, L, (recordname)

close 1

 

Hope that helps

 

 



Hello World!
brainfry
brainfry
Forum God
Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)Forum God (919 reputation)

Group: Forum Members
Posts: 59, Visits: 4

If that doesn't work, then you will need to increase the len higher than 852 until you no longer get that error.

 

 



Hello World!
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search