用VBscript排列和连接的数据库值

问题描述:

数据库中的值看起来像是10000000,10000001,10000002。现在我将值保存到一个字符串(ID)中,并且如果它的in和做一个连接,我想要分配一个新值,这样它就会以0a,1a,2b的形式出现。用VBscript排列和连接的数据库值

Dim LineOfText 
Dim i 
Dim aryTextFile(12) 
if ID.contains("10000000") then 
aryTextFile(9) = "0a" 
end if 
if ID.contains("10000002") then 
aryTextFile(10) = "1a" 
end if 
if ID.contains("10000001") then 
aryTextFile(11) = "2b" 
end if 

LineOfText = String.Join(",", aryTextFile) 

尝试这一点,给我的错误 Microsoft VBScript运行时错误 '800a01a8' 所需的

对象: '10000001,10000002'

那我做错了吗?

想过一些也许我没有把价值成一个字符串的权利。

strSQL = "SELECT ID from table where hdnID like 3696 " 
set objRec = Server.CreateObject("ADODB.Recordset") 
objRec.Open strSQL, cn, 0, 1 
Dim ID 
ID = objRec("ID") 

我在C#这个工作,但需要一个VBScript相当于 C#代码是

string[] Otherspace = new string[] { 1a, 2b, 3c }; 
       string txaNotes = String.Join(", ", Otherspace.Where(q => !string.IsNullOrEmpty(q))); 

试试这个:

LineOfText = join(aryTextFile, ",") 
+0

都能跟得上一些错误。 – alsu3 2012-03-11 18:18:07

+0

如果您发布错误,它会更有帮助。 – 2012-03-11 18:34:22

+0

在那里,但我想这足够描述。 – alsu3 2012-03-11 18:53:27

可以使用净进口构建数组,然后加入它。你如何能做到这一点

例子:

Dim DataList, ID 
ID = "10000000 foo 10000002 bar" 
Set DataList = CreateObject("System.Collections.ArrayList") 

If instr(ID, "10000000") Then DataList.Add "0a" 
If instr(ID, "10000001") Then DataList.Add "1a" 
If instr(ID, "10000002") Then DataList.Add "2b" 

LineOfText = join(DataList.ToArray, ", ") 
' LineOfText will have value "0a, 2b"