Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2006, 04:44 PM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default using a variable to specify excel file in ASP

I am trying to view an Excel page in ASP, but I want to use a variable to determine which file I want to pull. How can I get the below excel file, FILE, to be based on an input variable from the web page?

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("FILE.xls") & ";" & _
    "DRIVER={Microsoft Excel Driver (*.xls)};"

Thanks

 
Old March 28th, 2006, 05:38 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Try this

Dim strXLSFile
strXLSFile = "[path]"

Server.MapPath(strXLSFile)

Hope that helps.

"The one language all programmers understand is profanity."
 
Old March 29th, 2006, 02:44 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I assume what you are saying is brcd is a prefix for each excel file? if that is the case do something like tihs

dim strXLSFile
dim strFileSuffix

strXLSFile = "brcd"
strFileSuffix = Request.Form[QueryString]("fileSuffix")
strXLSFile = strXLSFile & strFileSuffix

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=\\JOHN\DDX Capital\Investment Summaries\" & srXLSFile & ";" & _
    "DRIVER={Microsoft Excel Driver (*.xls)};"

Hope that helps.

"The one language all programmers understand is profanity."
 
Old March 29th, 2006, 03:42 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Simple enough.

Dim strXLSFile
strXLSFile = Request.Form([form field name])

That will do it.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can´t creat excel file on a PC using ASP rtr1900 ASP.NET 2.0 Basics 6 October 29th, 2008 03:00 AM
To upload an Excel File to the Server using ASP SMM Classic ASP Professional 4 March 26th, 2007 03:49 AM
Impoting Excel file into Access Database using ASP prasanta2expert ASP.NET 1.0 and 1.1 Professional 0 October 5th, 2006 02:39 AM
Excel 2000 file to XML with ASP.net asn187 ASP.NET 2.0 Basics 1 February 13th, 2006 01:07 PM
Printing Excel File in ASP hkccwong Classic ASP Basics 1 January 5th, 2005 12:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.