小编Ale*_*xey的帖子

VBA,ADO.Connection和查询参数

我有excel VBA脚本:

Set c?nn = CreateObject("ADODB.Connection")
conn.Open "report"
Set rs = conn.Execute("select * from table" ) 
Run Code Online (Sandbox Code Playgroud)

脚本工作正常,但我想添加参数.例如"where(parentid = myparam)",其中myparam在查询字符串外设置.我该怎么做?

当然我可以修改查询字符串,但我认为这不是很明智.

vba ado

22
推荐指数
2
解决办法
7万
查看次数

如何使用一行代码在 C# 中连接两个数组

我有 C# 代码:

string[] names = new [] { "a", "b", "c" };
int[] vals = new[] { 5, 10, 15 };
r = "";
for( int i = 0; i < names.Length; i++ )
r += names[i] + ": " + vals[i] + " ";
Run Code Online (Sandbox Code Playgroud)

在 python 中我可以写 oneliner

r = " ".join( [ names[i] + ":" + str(vals[i]) for i in range(len(names)) ] )
Run Code Online (Sandbox Code Playgroud)

我怎样才能在 C# 中做到这一点?

c# linq

0
推荐指数
1
解决办法
376
查看次数

标签 统计

ado ×1

c# ×1

linq ×1

vba ×1