File Field control issues

A

ADM - Dan

I have an application that uses a file field control to get an Excel file
from the users local PC, then process the content of the file to update a
database table.

I am able to:
1. Get the file name
2. Use "postedFile.InputStream.Read(fileBytes, 0, FileLen)" to read the
file content into a byte array
3. Use "fStorage.Serialize(msStorage, fileBytes)" to serialize the byte
array into a memory stream.

When I try to deserialize the memory stream into a dataset, using "DS =
CType(fStorage.Deserialize(msStorage), DataSet)" or "DS =
fStorage.Deserialize(msStorage)", I get an error "Specified cast is not
valid".

What is happening here and how can I fix it? Could the binary formatter be
seeing that a column has numeric data in the first row, determining the
column should be of the integer data type based on the first row, then
encountering alpha data in the column?

Thanks.
 
P

paul

You can connect to a csv file (which can be opened in Excel and which
an Excel file can be converted into) in good form just as you can to a
regular database.

The .csv file needs to be uploaded to the server.

And you can have two recordsets open at the same time.

So I'd suggest going through this recordset one row at a time and
within this loop add a new record to the "real" database's recordset.

And for help connecting to a text file using the Jet OLE DB provider:
http://www.carlprothman.net/Default.aspx?tabid=87#OLEDBProviderForTextFiles

And based on the above link realize that the actual filename does NOT
go in the connection string - rather it goes in the SQL statement
(definitely a little tricky).

And here is a pure ASP (i.e. no components) resource for letting the
user upload a file which is something that was unfortunately not built
into ASP:

ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://aspzone.com/articles/160.aspx

The above free code has worked well for me and you can copy and paste
the code sample which is white on gray (what were they thinking?) or
just highlight it and it becomes black on white.

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top