Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VBscript be used for flattext database searches?

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

I am faced with a situation in which the search system of an online database system needs to be run locally as well.

A backup of the actual flattext database on the server is copied to the local harddisk. Now I need a program that is able to parse the file and do a search through it.

I was wondering if VBscript is able to do this?

This is the setup of the textfile:

uniquenr1|field1|field2|field3|field4|etc...
uniquenr2|field1|field2|field3|field4|etc...
etc.


Will VBscript be able to parse this file and create an array for each record? And after create an array for each record splitted by "|"!

Another question: at the moment the size of the file is almost 1 meg will this be a problem supposed that the above is possible in VBscript?

Hope somebody has experience with something like this!

Thanks anyway,

Ron
 
Well, you will need to use the fileSystemObject in vbScript to open and read the text file:


That will give you everything you need to know to open and read a text file.

After you have it open, then you will need to use the split() function to get your values into an array so you can iterate through it and do what you need to do:


hope that helps! :)
Paul Prewett

ps. check out the whole vbscript section of that site, for more information about any and all built-in vbscript functions. It's the best quick ref out there.
penny.gif
penny.gif
 
Thanks!

That will get me going!

Any ideas if the file size of 1 meg is going to be a problem?

Ron
 
The only problem that I could forsee there would be a memory problem -- vbScript will be able to handle it if your server can.

;-)
penny.gif
penny.gif
 
Ron:
I would recommend creating a disconnected recordset. To me, it is easier to sort any column you need sorted and to search for record information.

Parke
 
Parke I'm sorry I don't understand what you mean with "creating a disconnected recordset"?

Link9 I quess I will have to start this and experience whether the filesize is to large or not.

Meanwhile I had a look at the links above:

It gives an example of how to create a file and write to it:

<%
dim filesys, filetxt, getname, path
Set filesys = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set filetxt = filesys.CreateTextFile(&quot;c:\somefile.txt&quot;, True)
path = filesys.GetAbsolutePathName(&quot;c:\somefile.txt&quot;)
getname = filesys.GetFileName(path)
filetxt.WriteLine(&quot;Your text goes here.&quot;)
filetxt.Close
If filesys.FileExists(path) Then
Response.Write (&quot;Your file, '&quot; & getname & &quot;', has been created.&quot;)
End If
%>


Unfortunately there is no example of opening a file and read the the contents into a variable or so except from this piece of code:
object.OpenTextFile(filename [, iomode[, create[, format]]])

Is there anybody who can get me on the right track with this?

They do
 
Forget the last part &quot;They do&quot; I have no idea how that came there!

Ron
 
Safra:

Take a look at thread709-135824

and thread709-137255

Parke
 
Thanks dilettante, I just had a quick look at the link you posted. I will get into that aswell and see what works best for me and my limited knowledge for both solutions!

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top