thanks for your response.
now it give this error.
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Excel Driver] External table is not in the expected format.
/mtp/xl_data3.asp, line 32
I could not understand
"Do you have a named range in your Excel file called "TestData"? "
how I can do named range in excel file ?
in the excel file how can defined range of data ?
I am using following coding.
--------------------------------
Const adCmdText = 1
Const adOpenStatic = 3
Const adLockPessimistic = 2
Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols
Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("xl_data.xls") & ";" & "DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM testdata;", cnnExcel, adOpenStatic, adLockPessimistic
iCols = rstExcel.Fields.Count
%>
<table border="1">
<thead>
<%
For I = 0 To iCols - 1
Response.Write "<th>"
Response.Write rstExcel.Fields.Item(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
%>
</thead>
<%
rstExcel.MoveFirst
Do While Not rstExcel.EOF
Response.Write "<tr>" & vbCrLf
For I = 0 To iCols - 1
Response.Write "<td>"
Response.Write rstExcel.Fields.Item(I).Value
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write "</tr>" & vbCrLf
rstExcel.MoveNext
Loop
%>
</table>
<%
rstExcel.Close
Set rstExcel = Nothing
cnnExcel.Close
Set cnnExcel = Nothing
%>
Mateen
Quote:
quote:Originally posted by U.N.C.L.E.
Do you have a named range in your Excel file called "TestData"?
Are adOpenStatic and adLockPessimistic defined?
adOpenStatic and adLockPessimistic (and adCmdText) are defined in a file called adovbs.inc. If you can't find the file then use these:
Const adCmdText = 1
Const adOpenStatic = 3
Const adLockPessimistic = 2
rstExcel.Open "SELECT * FROM TestData;", cnnExcel, _
adOpenStatic, adLockPessimistic, adCmdText
|