Hi there,
Just a simple question, I think.
I'm writing a program that takes information from a text file and uses
that info to query a DB. Sounds simple enough.....
The data would look something like this
[t_customers]
cust_ref=MOL01
cust_addr_1=XYZ
Cust_Addr_2=ABC
Cust_Addr_3=LMN
Cust_Addr_4=QRS
Cust_Addr_5=DEF
etc
What I'd like to do is firstly remove the [] from the table name, and
secondly break the subsequent strings in two at the '=' therefore
having both a field name and data for each field.
Any idea how I'd manage this?
Cheers
P
I seem to be having trouble responding directly to your post bob, so
i'll just have to reply to myself! this is what I tried to say earlier
:
Hi there Bob,
To answer your questions:
1. I'm using MS SQL Server V8.0
2. Yeah there will be money, date/time data. All the DB will be
money/datetime.
Its pretty tricky. Using the code Ray gave me and a bot of my own I
was able to populate the DB to an extent. The extent being *one*
insert per loop. So I ended up filling one field in a row, moving to
the next row and filling another field etc.
I've written out what I think *may* work in pseudocode but I'm new to
asp and can't turn it into code proper.
something like
<code>
if readline includes "[" then
this is a *tablename*
so until next "["
all readlines are "fieldame = data"
-->smlArray = split(readline, =)
-->store all smlArrays into bigArray
-->so until loop finds another "["
-->bigarray should be bigarray(smlarray0, smallarray1,smlarray2, etc)
then using bigarray construct insert as
insert into *tablename*(bigarray.smlarray1(0), bigarray.smlarray1(0),
etc)
values (bigarray.smlarray1(1), bigarray.smlarray1(1),etc)
</code>
Or maybe I'm completely wrong.
I don't know if said or if i merely implied but there a numerous
different tables. The file *will* hold data that will reflect the DBs
structure.
I'll post some more sample data in a differnt post, as this one seems
a tad long for usenet!
I hate having to be a brain leech like this, thanks for any help.
P
Bob said:
Disregard my previous reply. I see what you're after.
1. What is the type and version of database you are using.
2. Your example data is all character (string) data. Will there be
numeric
or date/time data provided by these text files? Will the corresponding
table
fields be the same datatype (numeric or datetime)? Or are all the
fields
character fields?