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

Is there a way to get excel data without using a named range?

Status
Not open for further replies.

Cordel

Programmer
Aug 15, 2000
9
CA
here is what I have but i need to do it so the .xls creator does not need to create a named range.

<%

Const adOpenStatic = 3
Const adLockPessimistic = 2

Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols


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

' Same as any other data source.
' FYI: TestData is my named range in the Excel file
Set rstExcel = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rstExcel.Open &quot;SELECT * FROM TestData;&quot;, cnnExcel, _
adOpenStatic, adLockPessimistic

' Get a count of the fields and subtract one since we start
' counting from 0.
iCols = rstExcel.Fields.Count
%>

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top