我昨天问了这个问题并得到了答案。我通读了它并认为它可以工作,但是在将代码实现到我的 .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’
预期的语句结束
将 myList 调暗为 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
%>
这也是其中包含数据库和表名的实际代码