我有一个 for 循环,它显示了最后一项。我想获取所有项目并用作存储过程的参数。是否有一个基本原因,为什么它只会显示最后一项?
Dim Flipper As String
For x As Integer = 0 To EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles().Count - 1
Flipper = EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles(x).Name
Next
Stored Proc:
Select * From myTable Inner Join myOtherTalbe ON myTable.Id = myOtherTable.Id Where RoleId = @RoleId
VB CodeBehind:
Dim strConnection As String = "myDataSource"
Dim con As New SqlConnection(strConnection)
Dim cmd As New SqlCommand("mainForumA", con)
cmd.CommandType = CommandType.StoredProcedure
'params here if needed
cmd.Parameters.Add(New SqlParameter("@RoleId", Flippers))
con.Open()
Dim ds = New DataSet()
Dim da = New SqlDataAdapter(cmd)
da.Fill(ds)
cdcatalog.DataSource = ds
cdcatalog.DataBind()
con.Close()
如果我只有一个角色,那很好,但如果有多个角色,我需要:
Select * From myTable Inner Join myOtherTalbe ON myTable.Id = myOtherTable.Id Where RoleId = @RoleId1 Or RoleId = @RoleId2, etc