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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL, SQL, and ASP

Status
Not open for further replies.

TonyRosen

Programmer
Jul 28, 2003
108
US
Is there a way for my users to go to a web app ... and, "upload" their Excel spreadsheets into my SQL database?

I.E. - Contacts Information (name, address, etc)...

 
Hi,

I assume that your Excel Spreadsheets are tables.

Code:
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<% Server.ScriptTimeout = 1000 %>
<html>
<%
	Dim DB, rsEFF
	
    cst = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    cst = cst & server.mappath("Block Status TZT.mdb")

    Set DB = Server.CreateObject("ADODB.Connection")
    DB.Open cst
    Set rsEFF = Server.CreateObject("ADODB.Recordset")
    Sql = "SELECT * FROM BOM_1 BOM "

    rsEFF.Open SQL,DB,1,2
    do while not rsEFF.EOF
     'stuff
      rsEFF.MoveNext
    loop
    
......



Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
This FAQ may help you with your problem: faq333-3629
 
Medic ... thanks, but that FAQ deals with uploading a file ... I just want the contents ... basically, transfer contents from an excel file into my SQL database.

 
Right. You have to accept the upload of the file and store it. Then you grab the contents and process them. There's no magic way to not accept the upload and have it just drop into the database, at least not via ASP.
 
Ah! See? I didn't even THINK along those lines ... no WONDER it wasn't working ...
 
Or you could write some VBA code underneath the spreadsheet that will write to the database. I have done that before. And, you just place an event button on the spreadsheet surface or create a macro that will just run everything you want to the database.

Of course, you will have to design the VBA code to handle connections and SQL syntax. No problem.

So, the user just has to hit the button and all of the data is sent to the coded destination.





"I think there is a world market for maybe five computers."
--Thomas Watson, chairman of IBM, 1943

 
along the lines of ignoreme's post, you can interact a com component to make use of SQL's DTS abilities, and in turn could take the file upload/insert DB in a single phase with less issues.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Not all of my users are actually "on" our network... would this be a problem using either of these solutions?
 
no you'd incorporate the component built after a successful uploading via web.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
I hate when you guys give me something else to do ... ha!

Thanks!
 
i will make a forewarning.. building a component can be a [curse] to deal with, especially from scratch, i'd really digging into google for a few hours of different searches on ASP / ADO / Excel / Import / DTS / Com Component

someone might have one built 90% to your specs already.

as for the vba code in the spreadsheet, this could be compromiseable, and causes security issues. you can at least build server side filters/handling to where the only interaction from user to DB is sending a file for processing that may or may not pass specs.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
I figured that I would:

1) upload the file
2) redirect the user to an ASP page which will copy said data into the SQL database (since I will know the format of each)
3) delete the file
4) redirect user to a success page

Can that be any more simple?
 
The asp page that accepts the upload (the page it's posting to) can perform all 5 steps.

Page 1: Form that includes an upload field. Submits to Page 2.

Page 2: Copy data into the database, delete the file, display success (or failure).
 
What I ended up doing:

1) upload the file
2) Rename the file since every other sales person's file is named the same thing
3) redirect the user to an ASP page which will copy said data into the SQL database (since I will know the format of each) from the Excel file
3) delete the file
4) redirect user to a success page

And, it worked like a champ :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top