如何将数组参数从Asp.net传递到Sql statemint中的一个参数? [英] How To Pass Array Parameter From Asp.net To One Parameter In Sql statemint?

查看:57
本文介绍了如何将数组参数从Asp.net传递到Sql statemint中的一个参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将数组参数从Asp.net传递到Sql语句中的一个参数?
-------------------------------------------------- -------------------------

现在我想将数组参数传递给@id
就像下一个ex:

How To Pass Array Parameter From Asp.net To One Parameter In Sql statement???
---------------------------------------------------------------------------

now i wanna to pass array parameter to @id
like the next ex:

Dim arr As New ArrayList
       For Each row As GridViewRow In GridView1.Rows
           arr.Add(row.Cells(0).Text)
       Next
       Session("show_product") = arr
       Response.Redirect("show.aspx")



然后我去("show.aspx")

然后使用gridview1并将其与具有selectedvalue的sqldataource1绑定,像这样



then i go to ("show.aspx")

and but gridview1 and bind it with sqldataource1 with selectedvalue like that

select * from table where id in (@id)



但是参数无法获取ArrayList

最后我只想知道什么是数据类型,怎样才能携带像
这样的值 1,2,3,4,5等
而这种类型的苹果将@id复发到1,2,3,4,5

这样的Sql语句



but the parameter unable to get ArrayList

in the end i just wanna know what is the data type how is can carry values like
1,2,3,4,5 etc
and this type apple to relapse @id to 1,2,3,4,5
to Sql statement like

select * from table where id in (1,2,3,4,5)

推荐答案

将@id数据类型设置为varchar.在arraylist上使用循环可获取逗号分隔的输出.发送此逗号分隔值作为@id的输入.
Set @id datatype to varchar. Use loop on arraylist to get comma separated output. Send this comma separated value as input for @id.


这篇关于如何将数组参数从Asp.net传递到Sql statemint中的一个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆