Re: more on reading csv file into access

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Of course you get an error, you are assigning an array to a single string,
how on earth is it supposed to output the array, there is no magic where VB
can guess what you want and then format each element of the array and
present it correctly - YOU have to do all of that yourself. Each string
entry will need apostrophes, any dates will want # signs, each value will
need some sort of delimitation and you must iterate through the array
appending each element.

Here is a suggestion, take a random line from your file, now by hand work
out the SQL needed to add that to the database, once you have some good
working SQL you can then design the routine to generate that SQL. Trying to
write this sort of routine without knowing exactly what you need is doomed
to fail.

Regards
Dave O.

"inquirer" <noreply@xxxxxxxxxxx> wrote in message
news:46ef745e$0$13999$afc38c87@xxxxxxxxxxxxxxxxxxxxxxx
Further to my earlier post, I have a final (I hope) problem in actually
importing a csv file into Access (using vb6).
In the code below I get a "type mismatch" error when I try to run it at
the "&" before dataVals in the query

Dim dataVals() As String
Dim query as string

Do While Not EOF(1)
Line Input #1, txtNames
dataVals = Split(txtNames, ",")
query = "SELECT * INTO " & tblName & " IN '" & dbName & "' FROM " &
dataVals
dbBlock.Execute query
Loop
dbBlock.Close

tblName is the name of the table I want to insert the data into and dbName
is the full path to the database.
I do not know how to get the array of data values (dataVals) into the
query. The Split function is doing everything ok.
I have defined dataVals as a string array but the actual fields in the
data file are a mixture of numbers and text fields. I have set up the
table in Access so each field is correctly defined an number or text so
will the fact that dataVals is defined as strings cause a problem?
Note that in different data files there will be different numbers of
fields - that is ok as the creation of the table in the database takes
care of that.
Any help appreciated
Thanks
Chris


.



Relevant Pages

  • Re: loading a tab delimited data file into an array
    ... 1)open the data file ... 4)parse the string and assign each parsed string (seperated by a given ... delimiter) into an array slot ... "Dinesh Narayan" wrote in message ...
    (microsoft.public.vc.language)
  • Re: need help reading contents of a file into an array...SKYPE ME.
    ... Dim fields As String() ... I've got a .txt data file with a name, pin, balance seperated by ... read it into an array and then check if what was entered as a name by ... Please Skype me, using the Text chat of skype. ...
    (microsoft.public.dotnet.languages.vb)
  • more on reading csv file into access
    ... In the code below I get a "type mismatch" error when I try to run it at the "&" before dataVals in the query ... Dim dataVals() As String ... I have defined dataVals as a string array but the actual fields in the data file are a mixture of numbers and text fields. ...
    (microsoft.public.vb.general.discussion)
  • Re: Search in data
    ... I have a data file with alphanumeric caracters, as a table in ascii, ... I need to find the string Presidentand then Take the population ... where matlab manipulations are probably more native. ... if you had an array of structures 'data' with the fields 'country', ...
    (comp.soft-sys.matlab)
  • Re: sort string beginning at index?
    ... from the beginning of the string, but from a given index into the string. ... I am reading a data file into an array using file, then looping through the string which contains fields seperated by |. ... Do I have to explode each individual record to sort them using array_multisort? ...
    (alt.php)