这是我的代码:
Dim CompanyName, _
CompanyDomain, _
CompanyEmail, _
CompanySupportPhone
Call GetEmailList
Sub GetEmailList
dim sql
dim companydata
sql = ""
sql = sql & " DECLARE @CompanyName VARCHAR(100);"
sql = sql & " DECLARE @CompanyDomain VARCHAR(100);"
sql = sql & " DECLARE @CompanyActivityEmail VARCHAR(100);"
sql = sql & " DECLARE @CompanySupportPhone VARCHAR(100);"
sql = sql & " SELECT"
sql = sql & " @CompanyName = CASE WHEN Setting = 'CompanyName'"
sql = sql & " THEN StringValue ELSE @CompanyName END,"
sql = sql & " @CompanyDomain = CASE WHEN Setting = 'CompanyDomain'"
sql = sql & " THEN StringValue ELSE @CompanyDomain END,"
sql = sql & " @CompanyActivityEmail = CASE WHEN Setting = 'CompanyActivityEmail'"
sql = sql & " THEN StringValue ELSE @CompanyActivityEmail END,"
sql = sql & " @CompanySupportPhone = CASE WHEN Setting = 'CompanySupportPhone'"
sql = sql & " THEN StringValue ELSE @CompanySupportPhone END"
sql = sql & " FROM ClientSettings"
sql = sql & " WHERE Setting in ('CompanyDomain','CompanyActivityEmail','CompanySupportPhone','CompanyName')"
sql = sql & " SELECT ISNULL(@CompanyName, '') AS CompanyName, ISNULL(@CompanyDomain, '') AS CompanyDomain, ISNULL(@CompanyActivityEmail, '') AS CompanyEmail, ISNULL(@CompanySupportPhone, '') AS CompanySupportPhone"
set companydata = getRecordset(sql)
CompanyName = companydata("CompanyName") ' LINE 80
CompanyDomain = companydata("CompanyDomain")
CompanyEmail = companydata("CompanyEmail")
CompanySupportPhone = companydata("CompanySupportPhone")
companydata.Close
Set companydata = Nothing
End Sub
这会引发错误:
80 号线
在与请求的名称或序号对应的集合中找不到项目。
我在上面标记了第 80 行。我在 SQL Server 管理器中运行这个完全相同的 SQL 并返回结果:
CompanyName CompanyDomain CompanyEmail CompanySupportPhone
MyCompanyName http://localhost MyCompanyName@email.com 801-555-1212
知道我在这里做错了什么吗?
GetRecordSet 正确加载和处理数据库调用,此函数在 1,000 个其他地方有效。我确定问题不存在。