473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Grr, I can't find the answer!

Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you
fella's talking up one side and down the other about streams, and can't for
the life of me get a good grasp of them. I've been reading the articles you
toss around to each other but I can't quite follow them enough to know why
and how I'm supposed to be using streams instead of the FileGet and FilePut
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as
long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut
seem to be just so dad-blasted slow these days, even on fast machines. I
know these machines should be able to search the entire file in less time
than it takes me to think about it, but gosh it takes quite a little while,
which slows down the program considerably, so there must be a better way.

That Microsoft book I've been using says that streams are great, and
even gives a little example of using them. My problem is that I can't
figure out how to use them in place of the random access file routines
FileGet and FilePut. I've tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I've found
however, doesn't help me to learn how to open a stream to a file and then
send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I'm sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I would
be very greatful.

Here's a very simplified example of what I've managed to put together out of
all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of "File
Streams for Dummy's", I would be most greatful, as I don't want anybody to
feel they are doing my work for me.
Nov 20 '05 #1
18 1643
you can have a top clas that contain all records in an array or some
collection and serialize that class as you did with a record

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:fi***************@newsread1.news.pas.earthlin k.net...
Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you fella's talking up one side and down the other about streams, and can't for the life of me get a good grasp of them. I've been reading the articles you toss around to each other but I can't quite follow them enough to know why
and how I'm supposed to be using streams instead of the FileGet and FilePut stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut seem to be just so dad-blasted slow these days, even on fast machines. I
know these machines should be able to search the entire file in less time
than it takes me to think about it, but gosh it takes quite a little while, which slows down the program considerably, so there must be a better way.

That Microsoft book I've been using says that streams are great, and
even gives a little example of using them. My problem is that I can't
figure out how to use them in place of the random access file routines
FileGet and FilePut. I've tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I've found however, doesn't help me to learn how to open a stream to a file and then
send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I'm sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I would be very greatful.

Here's a very simplified example of what I've managed to put together out of all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of "File
Streams for Dummy's", I would be most greatful, as I don't want anybody to
feel they are doing my work for me.

Nov 20 '05 #2
"strchild" <st******@hotmale.com> schrieb
Here's a very simplified example of what I've managed to put together
out of all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class
The data types are missing:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name As String
<VBFixedString(32)> Public addressLine1 As String
<VBFixedString(32)> Public addressLine2 As String
<VBFixedString(32)> Public addressLine3 As String
End Class

Enabling Option Strict prevents you from these errors.
Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt",
FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let
me save more than one address into my address file, like I could if I
were using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

I'm not a friend of serialization, but AFAIK you can not do it this way.
Serialization is an object oriented way to store data. It's stored
sequentially, not record by recored, i.e. there is no guarantee that all
records have the same length - but that has to be assumed for a random
access file. What you can do (using serialization) is use or write a
serializable collection containing all instances to be stored. Then you can
serialize the whole collection instead.

If I needed a random access file, I'd use fileget/fileput (without having
deeper experience in it's performance), or I'd use a BinaryWriter that
writes the contents to the file (bit by bit, integer by integer,...).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #3
I'm afraid I don't understand what you mean, Cirus. Do you mean to just
open the file and load in every last record that I have stored in it, all at
once? That doesn't make sense to me! One of my files that I have to manage
records in is hundreds of megabytes.

I'm afraid that I'm a dummy yet again and don't know what a "Top Class"
is.

I can give more background on my program, if anybody wants, but I didn't
think it necessary to make my original post any longer than it already is!

I do appreciate the help though.

Confused even more, ;-S
Brian

"Crirus" <Cr****@datagroup.ro> wrote in message
news:OK*************@tk2msftngp13.phx.gbl...
you can have a top clas that contain all records in an array or some
collection and serialize that class as you did with a record

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:fi***************@newsread1.news.pas.earthlin k.net...
Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you
fella's talking up one side and down the other about streams, and can't

for
the life of me get a good grasp of them. I've been reading the articles

you
toss around to each other but I can't quite follow them enough to know why and how I'm supposed to be using streams instead of the FileGet and

FilePut
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as
long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut
seem to be just so dad-blasted slow these days, even on fast machines.

I know these machines should be able to search the entire file in less time than it takes me to think about it, but gosh it takes quite a little

while,
which slows down the program considerably, so there must be a better way.
That Microsoft book I've been using says that streams are great, and
even gives a little example of using them. My problem is that I can't
figure out how to use them in place of the random access file routines
FileGet and FilePut. I've tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I've

found
however, doesn't help me to learn how to open a stream to a file and then send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I'm sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I

would
be very greatful.

Here's a very simplified example of what I've managed to put together out of
all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of

"File Streams for Dummy's", I would be most greatful, as I don't want anybody to feel they are doing my work for me.


Nov 20 '05 #4
Ugg, Armin, thanks for the input. See, that's just it. As far as I can
figure, I need a random access file, as I don't know which record a user
will want at any given time until they ask for it specifically or search
through the records to find it. Unfortunately, the FileGet and FilePut
routines are turning out to be rediculously slow, even on 1 GHz + machines,
so I feel I have to use a more efficient method. I asked this question a
while back, and was told to look into Serialization. I hope I haven't been
plodding down the wrong road! If I have, I would gladly take a bump on the
head and a point in a more useful direction.

Good catch on the missing data types. It's late, and I typed in the
code by hand as I don't like how it pastes into Outlook Express at five in
the morning, so actually the data types are in my program the way they
should be.

Thank you for the thoughts on using a BinaryWriter. I will look into that
and see if I can muster anything.

I'm afraid I can't grasp what you and Crirus mean about handling all of
the records at once. I just want to work with a single record, really, and
have the rest in my file! I'm sure I am thinking too old fashioned, but I
can't seem to help it with this.

Thank you again,
Brian

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eF*************@TK2MSFTNGP12.phx.gbl...
"strchild" <st******@hotmale.com> schrieb
Here's a very simplified example of what I've managed to put together
out of all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class
The data types are missing:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name As String
<VBFixedString(32)> Public addressLine1 As String
<VBFixedString(32)> Public addressLine2 As String
<VBFixedString(32)> Public addressLine3 As String
End Class

Enabling Option Strict prevents you from these errors.
Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt",
FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let
me save more than one address into my address file, like I could if I
were using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

I'm not a friend of serialization, but AFAIK you can not do it this way.
Serialization is an object oriented way to store data. It's stored
sequentially, not record by recored, i.e. there is no guarantee that all
records have the same length - but that has to be assumed for a random
access file. What you can do (using serialization) is use or write a
serializable collection containing all instances to be stored. Then you

can serialize the whole collection instead.

If I needed a random access file, I'd use fileget/fileput (without having
deeper experience in it's performance), or I'd use a BinaryWriter that
writes the contents to the file (bit by bit, integer by integer,...).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #5
question

you'll probably have a good reason for this but why don't you use a
database? (it dousn't have to be an sqlserver) any database (they work a lot
faster, and wil give you less problems to implement)

eric
"strchild" <st******@hotmale.com> wrote in message
news:tZ***************@newsread1.news.pas.earthlin k.net...
Ugg, Armin, thanks for the input. See, that's just it. As far as I can figure, I need a random access file, as I don't know which record a user
will want at any given time until they ask for it specifically or search
through the records to find it. Unfortunately, the FileGet and FilePut
routines are turning out to be rediculously slow, even on 1 GHz + machines, so I feel I have to use a more efficient method. I asked this question a
while back, and was told to look into Serialization. I hope I haven't been plodding down the wrong road! If I have, I would gladly take a bump on the head and a point in a more useful direction.

Good catch on the missing data types. It's late, and I typed in the
code by hand as I don't like how it pastes into Outlook Express at five in
the morning, so actually the data types are in my program the way they
should be.

Thank you for the thoughts on using a BinaryWriter. I will look into that
and see if I can muster anything.

I'm afraid I can't grasp what you and Crirus mean about handling all of the records at once. I just want to work with a single record, really, and have the rest in my file! I'm sure I am thinking too old fashioned, but I
can't seem to help it with this.

Thank you again,
Brian



Nov 20 '05 #6
Cor
Hi Strchild,

I am just curious, why are you not going like everybody else to a database?

Cor
Nov 20 '05 #7
Cor
Hi EricJ,

And in the same time,

:-))

Cor
Nov 20 '05 #8
we think alike ;p

"Cor" <no*@non.com> wrote in message
news:uB**************@TK2MSFTNGP12.phx.gbl...
Hi Strchild,

I am just curious, why are you not going like everybody else to a database?
Cor

Nov 20 '05 #9
You're both right but, and bear with me, my program in VB.NET is a
rewrite of something my dad had me do for him a few years ago. I didn't
think too much of it at the time, but the project has since ballooned into
an ugly albatross. Please don't freak out, but the first version was in
QBASIC, and it worked really rather well. Had my inlined assembly routine
to give me mouse support and everything, but of course, that was a far cry
from what I really needed if I was going to keep adding features to the
program, so I upgraded to the latest VB which was .NET 2002 at the time, and
well, haven't looked back.

As for database programming, I really haven't got the first clue what
that would involve, and as much as I can, I want this thing to be self
contained and not need anything else such as Microsoft Access or whatever it
would take to add a true database to it. However, more speed is what I need
right now, so I can give information to my users much more efficiently, and
if that means buying a copy of Access for myself so I can create a database,
I will. From there however, I'm really rather nervous the scale of learning
I'm up against for just creating a really quick, really simple database, and
interfacing it to my program.

What I have right now works, but it's slow to search through records,
and slow for other tasks, and I would really like to provide a much faster
way of doing things.

How would a commercial database product compare to just doing it myself,
as I've been so far? Would I need to purchase the database product for each
installed copy of my program, or do I just need one copy of the database
program for creating the database on my developement machine?
Unfortunately, like I said, I don't have the first clue about professional
databases, so I just make my own home-grown versions, when I need.

~Brian
"EricJ" <ericRéMo**@ThiSomnipack.be> wrote in message
news:3f***********************@reader0.news.skynet .be...
question

you'll probably have a good reason for this but why don't you use a
database? (it dousn't have to be an sqlserver) any database (they work a lot faster, and wil give you less problems to implement)

eric
"strchild" <st******@hotmale.com> wrote in message
news:tZ***************@newsread1.news.pas.earthlin k.net...
Ugg, Armin, thanks for the input. See, that's just it. As far as I

can
figure, I need a random access file, as I don't know which record a user
will want at any given time until they ask for it specifically or search
through the records to find it. Unfortunately, the FileGet and FilePut
routines are turning out to be rediculously slow, even on 1 GHz +

machines,
so I feel I have to use a more efficient method. I asked this question a while back, and was told to look into Serialization. I hope I haven't

been
plodding down the wrong road! If I have, I would gladly take a bump on

the
head and a point in a more useful direction.

Good catch on the missing data types. It's late, and I typed in the
code by hand as I don't like how it pastes into Outlook Express at five in the morning, so actually the data types are in my program the way they
should be.

Thank you for the thoughts on using a BinaryWriter. I will look into that and see if I can muster anything.

I'm afraid I can't grasp what you and Crirus mean about handling all

of
the records at once. I just want to work with a single record, really,

and
have the rest in my file! I'm sure I am thinking too old fashioned, but I can't seem to help it with this.

Thank you again,
Brian


Nov 20 '05 #10
msde is a free small version of sql server (havent used it, we have a full
sql server)
if im not mistaking there is something included in visual studio to make
small db's
access you would buy access for you, make a db and distribute the db file w
your app (no extra costs, what costs are there if you send someone a word
doc and you have made a word doc reader yourself ?)

the speed increase would be big, very big

learning (if you can manage the data in flat files you really wont have a
problem w making a small db)
and there is enough help out there (and here)
Nov 20 '05 #11
Thank you EricJ. That's what I was thinking, with Access, anyway. I am
not sure I am up to the task of anything SQL right now, after browsing and
reading through nightmarish seeming posts for a year and a half now. My
brother actually has a copy of Access 97, he bought but never useses, I will
look at to see if it could handle something of this sort. Would a version
that old have any interfacing problems with something as recent as VB.NET
2003?

I would look into the small database thingie in Visual Studio, but as
I'm mostly just a hobby programmer, I just have the VB.NET 2002 and 2003
standard editions. I must say though, for a hundred smackers each, I
couldn't be happier. I can do everything I ever need, I feel, cept just
need to bite the bullet and learn simple database stuff using real products,
not just my backwater moonshine renditions.

Thank you very much for everything so far,
Brian

"EricJ" <ericRéMo**@ThiSomnipack.be> wrote in message
news:3f***********************@reader3.news.skynet .be...
msde is a free small version of sql server (havent used it, we have a full
sql server)
if im not mistaking there is something included in visual studio to make
small db's
access you would buy access for you, make a db and distribute the db file w your app (no extra costs, what costs are there if you send someone a word
doc and you have made a word doc reader yourself ?)

the speed increase would be big, very big

learning (if you can manage the data in flat files you really wont have a
problem w making a small db)
and there is enough help out there (and here)

Nov 20 '05 #12
>My
brother actually has a copy of Access 97, he bought but never useses, I will look at to see if it could handle something of this sort. Would a version
that old have any interfacing problems with something as recent as VB.NET
2003?


good question
i don't think there will be problems (and creating a db in access is
peanuts)

Nov 20 '05 #13
"strchild" <st******@hotmale.com> wrote...
What I have right now works, but it's slow to search through records,
and slow for other tasks, and I would really like to provide a much faster
way of doing things.


Brian: I don't think I saw it posted but is this a single-user app? If the
data is used by only one person you have considerably more flexibility.

Also... ADO (as far as I know) provides a level of abstraction regardless of
the data source. There is a driver that supports text files and you should
be able to access a text file as a dataset.

Tom
Nov 20 '05 #14
Remember, Access databases have a 1GB limitation for each table, but
they would be much easier to use if you know how to use the Data
classes. You only need to buy Access if you want to use it, not if
you want to use the Access MDB file format. VS.Net Server Explorer
should be able to open an access database file easily, just set up a
connection to it using the Jet 4.0 OLE DB provider.

Streams are very, very easy once you understand that they are
essentially arrays. To do a search, you have to read through the
entire stream/array, piece by piece. To do an insert, you have append
some blank space, then copy all data after the insertion point to the
end of the stream, then insert in the vacated space. To do a delete
also involves copying at most the entire file. To read or overwrite
in the middle of a stream, you have to seek to that position first.
If you need to do a lot of inserts/deletes in a large dataset, then
definitely go with a database because streams will become really slow.

Here's some code that can get you started. All it does is copy from
one stream into another stream. It's fairly straightforward to adapt
this loop to do searching in a file instead. FileStreams only allow
byte level access, but you can use other stream types for depending on
what you need, like TextReader and TextWriter. They all work
similarly. Note, index 0 indicates the starting position in the byte
array Buffer, not a position in the file stream. Part of the speed
comes from the fact that you don't read the entire file into memory at
once.

Imports System.IO
Module Test
Sub Main()
Const BytesPerRead = 65536
Dim Buffer(BytesPerRead) As Byte
Dim BytesRead As Long

Dim objInputStream As FileStream = File.OpenRead("infile.txt")
Dim objOutputStream As FileStream = File.OpenWrite("outfile.txt")

BytesRead = 1
Do While BytesRead <> 0
BytesRead = objInputStream.Read(Buffer, 0, BytesPerRead)
If BytesRead <= 0 Then
Exit Do
End If
objOutputStream.Write(Buffer, 0, BytesRead)
Loop

objOutputStream.Close()
objInputStream .Close()

End Sub
End Module

Nov 20 '05 #15
In article <fi***************@newsread1.news.pas.earthlink.ne t>, strchild wrote:
Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you
fella's talking up one side and down the other about streams, and can't for
the life of me get a good grasp of them. I've been reading the articles you
toss around to each other but I can't quite follow them enough to know why
and how I'm supposed to be using streams instead of the FileGet and FilePut
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as
long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut
seem to be just so dad-blasted slow these days, even on fast machines. I
know these machines should be able to search the entire file in less time
than it takes me to think about it, but gosh it takes quite a little while,
<snip>
P.S. Maybe if anybody knew of a book or article along the lines of "File
Streams for Dummy's", I would be most greatful, as I don't want anybody to
feel they are doing my work for me.


Random file access in using the stream classes is sort of a pain....
You can't have fixed length strings and arrays, etc. VB.NET adds the
attributes and functions that understand those attributes, but the cost
is very bad performance.

You are much better off doing it manually. I found an article that may
help you - if you decide to go this route, but I would as others have
suggested use a database - MSDE would probably be a prefect fit :). Anyway,
here's the link:

http://www.vbrelated.com/vb/ch17/17_07/

HTH
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #16
Hi Brian,

See if any of your local colleges offer Access courses - I'd be
surprised if there aren't dozens (slight exag! ;-)). Some will simply be for
users - creating, querying, etc. Some will take you as far as programming
(within Access using VBA). You'll only need a term or two. And, either way,
you'll come out of the course thinking 'this is sooo simple'. Programming it
from VB.NET will then be much more straightforward.

Of course there's nothing to stop you overlapping the two for you'll get
the gist of the DB thing in a couple of weeks (especially if you are
diligent with the book) and can then start asking how to use ADO. (You'll
have to do it monkey fashion for a while - monkey see, monkey do - until it
clicks).

Regards,
Fergus
Nov 20 '05 #17
Thank you to everybody for helping me make my decision to learn database
programming. I think that it's a wonderful idea to dive in and find a
course at my local college. Umm, one last question I have though if anybody
knows, will I have to upgrade my VB.NET Standard to be able to interface
with MS Access or any of the other popular databases?

Thanks for everything, guys,
Brian

"Tom Shelton" <to*@mtogden.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
In article <fi***************@newsread1.news.pas.earthlink.ne t>, strchild wrote:
Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you fella's talking up one side and down the other about streams, and can't for the life of me get a good grasp of them. I've been reading the articles you toss around to each other but I can't quite follow them enough to know why and how I'm supposed to be using streams instead of the FileGet and FilePut stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut seem to be just so dad-blasted slow these days, even on fast machines. I know these machines should be able to search the entire file in less time than it takes me to think about it, but gosh it takes quite a little while,
<snip>
P.S. Maybe if anybody knew of a book or article along the lines of
"File Streams for Dummy's", I would be most greatful, as I don't want anybody to feel they are doing my work for me.


Random file access in using the stream classes is sort of a pain....
You can't have fixed length strings and arrays, etc. VB.NET adds the
attributes and functions that understand those attributes, but the cost
is very bad performance.

You are much better off doing it manually. I found an article that may
help you - if you decide to go this route, but I would as others have
suggested use a database - MSDE would probably be a prefect fit :).

Anyway, here's the link:

http://www.vbrelated.com/vb/ch17/17_07/

HTH
--
Tom Shelton
MVP [Visual Basic]

Nov 20 '05 #18
Nevermind, I thought you have some records and real with store them, not a
database-like system

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:HQ***************@newsread1.news.pas.earthlin k.net...
I'm afraid I don't understand what you mean, Cirus. Do you mean to just open the file and load in every last record that I have stored in it, all at once? That doesn't make sense to me! One of my files that I have to manage records in is hundreds of megabytes.

I'm afraid that I'm a dummy yet again and don't know what a "Top Class" is.

I can give more background on my program, if anybody wants, but I didn't think it necessary to make my original post any longer than it already is!

I do appreciate the help though.

Confused even more, ;-S
Brian

"Crirus" <Cr****@datagroup.ro> wrote in message
news:OK*************@tk2msftngp13.phx.gbl...
you can have a top clas that contain all records in an array or some
collection and serialize that class as you did with a record

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:fi***************@newsread1.news.pas.earthlin k.net...
Hey Guys,

I've been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by Step Version 2003, over and over, and I feel like such a dummy. I read
you
fella's talking up one side and down the other about streams, and
can't
for
the life of me get a good grasp of them. I've been reading the
articles you
toss around to each other but I can't quite follow them enough to know
why and how I'm supposed to be using streams instead of the FileGet and

FilePut
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for
as
long as I can remember, and I don't know how to be more efficient with
things although I've read that streams are so much faster than the old
routines. I have a little file I'm working with that stores names and
address and is searched through on a regular basis, but FileGet and

FilePut
seem to be just so dad-blasted slow these days, even on fast machines.

I know these machines should be able to search the entire file in less time than it takes me to think about it, but gosh it takes quite a little

while,
which slows down the program considerably, so there must be a better way.
That Microsoft book I've been using says that streams are great,
and even gives a little example of using them. My problem is that I can't
figure out how to use them in place of the random access file routines
FileGet and FilePut. I've tried to figure this out before, and was sent down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I've

found
however, doesn't help me to learn how to open a stream to a file and

then send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I'm sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I

would
be very greatful.

Here's a very simplified example of what I've managed to put together out
of
all the information I've run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don't understand yet is how I can modify the above code to let me save more than one address into my address file, like I could if I were using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of

"File Streams for Dummy's", I would be most greatful, as I don't want
anybody to feel they are doing my work for me.



Nov 20 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Arne | last post by:
Hi, Probably an easy answer to this, but I have not been able to figure it out. How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in...
3
by: Mark R | last post by:
I have one .asp page with a SELECT pulldown list on it and some INPUT fields. When SUBMIT is clicked the form data is submitted to that same page and validated. If INPUT fields are empty the asp...
4
by: Robert W. | last post by:
I'm thinking of building a complex data model with a number of nested classes but need to know something first. To simplify my question, let me present you this sample data model MainClass...
11
by: volcs0 | last post by:
I've done this in Scheme, but I'm not sure I can in Python. I want the equivalent of this: if a == "yes": answer = "go ahead" else: answer = "stop" in this more compact form:
4
by: Rich | last post by:
Hello, I need to store various values that I will need to look up later on. I have been using hashtables and arraylists. But I can only store 2 items per row in a hashtable - key, value, and...
8
by: Mr. SweatyFinger | last post by:
where have they all gone. alt.suicide? alt.findContol.then.slit.your.own.throat?
6
by: Salman | last post by:
I would like to know how I can distribute the application that I create with Visual C++ express edition. I checked the menu options to find a deploy option similar to the one found on the Visual...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
15
by: Christian Blackburn | last post by:
Hi Gang, I have come across something that I wouldn't believe unless I'd seen it with my own eyes, a DOS program with an icon. Can someone tell me how to change the icon, my company no longer...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.