【发布时间】:2013-04-11 13:51:50
【问题描述】:
我昨天问了this question,得到了答复。我通读了它并认为它可以工作,但是在将代码实现到我的 .asp 页面后,我得到了一个错误。
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("DatabaseName.mdb")
Set rsLogbook = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT TableName.FieldName FROM TableName;"
rsLogbook.Open strSQL, adoCon
'' get string and put into list
Dim myList As List(Of String) = rsLogbook("FieldName").ToString().Split(New () {","}, StringSplitOptions.RemoveEmptyEntries).ToList()
'' then close all your stuff
rsLogbook.Close
Set rsLogbook = Nothing
Set adoCon = Nothing
'' Sort your list
myList.Sort();
'' now output to where ever you want.
'' in this case, have an asp.literal control on your page where you want the text and call it myLit
For each sensor in myList
myLit.Text += "<p>" + sensor + "</p>"
Next
%>
错误提示
"Microsoft VBScript 编译错误'800a0401'
预期语句结束
Dim myList As List(Of String) = rsLogbook("sensors").ToString().Split(New () {","}, StringSplitOptions.RemoveEmptyEntries).ToList() ------------^
我非常感谢任何帮助。
我在这里尝试使用此代码做的是从数据库中提取信息并使用 .asp 和 VB 脚本将其显示在网页中。我正在使用.asp页面中的Response.Write标签来实现包含数据库中信息的字段名称
更新
<%
Dim adoCon
Dim rsLogbook
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*accdb, *.mdb)}; DBQ=" & Server.MapPath("featuredvehicle.accdb")
Set rsLogbook = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT featuredvehicles.make FROM featuredvehicles;"
rsLogbook.Open strSQL, adoCon
Response.Write ("<br>")
Response.Write (rsLogbook("make"))
rsLogbook.Close
Set rsLogbook = Nothing
Set adoCon = Nothing
%>
这是包含数据库和表名的实际代码
【问题讨论】:
-
您正在使用 c# 代码并尝试在 vbscript/ASP 中重写?您需要重写解释器指向的整行 - 这样的结构以及大多数方法在 vbscript 中不可用。
-
你能帮我用经典的 asp 而不是 asp.net 重新编写这段代码
标签: database asp-classic vbscript