Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:如何根据参数个数动态增加?

1楼
HappyFt 发表于:2024/5/30 22:46:00

dim cols as string = "来源单号,产品编码"

Dim cs() As String = cols.split(",") '拆分字符串为数组

dim i2 as integer = cs.length   '如果是2个参数就写2个问号,3个就写3个问号?

cmd.CommandText = "Select 需求数量,累计数量 from dbo." & ufnName & "(?,?)" 

For i As Integer = 0 To cs.Length - 1 '动态传入参数

      cmd.Parameters.Add("@" & cs(i), dr(cs(i)))

 Next

 

如上面函数动态传参时如何实现红色部份变动

谢谢!

2楼
有点蓝 发表于:2024/5/30 23:33:00

dim cols as string = "来源单号,产品编码"

Dim cs() As String = cols.split(",") '拆分字符串为数组

dim s as string 

For i As Integer = 0 To cs.Length - 1 '动态传入参数

      cmd.Parameters.Add("@" & cs(i), dr(cs(i)))

s = s & "?,"

 Next

cmd.CommandText = "Select 需求数量,累计数量 from dbo." & ufnName & "(" & s.trim(",") & ")" 

 

3楼
HappyFt 发表于:2024/5/31 9:52:00
原来以为cmd.Parameters.Add只能放在select函数的后面,可以放在前面拼接就简单了,谢谢!
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.