asp读取excel失败
为什么url得不到rs(0)的值呀Dimupxls,urlDimIDID=Request("ID")'文章编号IfIsNumeric(ID)andlen(ID)>0and...
为什么url得不到rs(0)的值呀
Dim upxls, url
Dim ID
ID = Request("ID") ' 文章编号
If IsNumeric(ID) and len(ID) > 0 and len(ID) < 10 Then
Dim Plus
Set Plus = New Cls_Plus
Plus.Open("upload") ' 打开配置文件
Dim Rs : Set Rs = DB("Select [upxls] From [{pre}Content] Where [ID]=" & ID,1)
If Not Rs.Eof Then
url=Server.MapPath( "& Rs(0) &" )
Response.Write "url"
End If
Rs.Close : Set Rs = Nothing
Set Plus = Nothing
End If 展开
Dim upxls, url
Dim ID
ID = Request("ID") ' 文章编号
If IsNumeric(ID) and len(ID) > 0 and len(ID) < 10 Then
Dim Plus
Set Plus = New Cls_Plus
Plus.Open("upload") ' 打开配置文件
Dim Rs : Set Rs = DB("Select [upxls] From [{pre}Content] Where [ID]=" & ID,1)
If Not Rs.Eof Then
url=Server.MapPath( "& Rs(0) &" )
Response.Write "url"
End If
Rs.Close : Set Rs = Nothing
Set Plus = Nothing
End If 展开
1个回答
展开全部
用rs(0),rs(1)列索引的方式读取试试
=======================================
以下代码已经经过测试:
<%
Dim objConn,objRS
Dim strConn,strSql
dim lRecCount
set objConn=Server.CreateObject("ADODB.Connection")
set objRS=Server.CreateObject("ADODB.Recordset")
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & server.mappath
("test.xls")
objConn.Open strConn
strSql="SELECT * FROM [Sheet1$]"
objRS.Open strSql,objConn,1,1
lRecCount=objRS.RecordCount
response.write "数据总数:" & CStr(lRecCount) & "<br>"
objRS.MoveFirst
while not objRS.eof
response.write objRS(0) & "----" & objRS(1) & "-------" & objRS(2) & "-------" & objRS(3) & "-------" & objRS(4)
& "<br>"
objRS.MoveNext
wend
objRS.Close
objConn.Close
set objRS = Nothing
set objConn = Nothing
%>
EXECEL中的数据内容为:
aaa bb3 77sc a3d7 8ds3lkl asdf324
34rwqwe 34532rwe 32ter 45345t4 er324 rwe5r34
23ew 4324 32 43ds sdfd 323
wse we 23 322 sdd dsd
=======================================
以下代码已经经过测试:
<%
Dim objConn,objRS
Dim strConn,strSql
dim lRecCount
set objConn=Server.CreateObject("ADODB.Connection")
set objRS=Server.CreateObject("ADODB.Recordset")
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & server.mappath
("test.xls")
objConn.Open strConn
strSql="SELECT * FROM [Sheet1$]"
objRS.Open strSql,objConn,1,1
lRecCount=objRS.RecordCount
response.write "数据总数:" & CStr(lRecCount) & "<br>"
objRS.MoveFirst
while not objRS.eof
response.write objRS(0) & "----" & objRS(1) & "-------" & objRS(2) & "-------" & objRS(3) & "-------" & objRS(4)
& "<br>"
objRS.MoveNext
wend
objRS.Close
objConn.Close
set objRS = Nothing
set objConn = Nothing
%>
EXECEL中的数据内容为:
aaa bb3 77sc a3d7 8ds3lkl asdf324
34rwqwe 34532rwe 32ter 45345t4 er324 rwe5r34
23ew 4324 32 43ds sdfd 323
wse we 23 322 sdd dsd
追问
那个"test.xls"这个不确定 是变量 当id不一样时 调取 这个代码该怎样改一下啊 拜托 帮帮忙
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询