Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 是否可以从选定的SQL Server检查表中进行选择_Asp.net_Vb.net - Fatal编程技术网

Asp.net 是否可以从选定的SQL Server检查表中进行选择

Asp.net 是否可以从选定的SQL Server检查表中进行选择,asp.net,vb.net,Asp.net,Vb.net,我有一个查询选择,我需要的是选择选中复选框列表中的数据。可能吗 这是我的问题:我尝试使用-IN-但我认为这不是解决方案 SELECT [scod], [ecode], [scty] ,[sonm] FROM [Z_ALI].[dbo].[M_STORE] WHERE [scod] IN ('FROMTHECHECKLIST') 我正试着这样做: For Each row As GridViewRow In GridView1.Rows

我有一个查询选择,我需要的是选择选中复选框列表中的数据。可能吗

这是我的问题:我尝试使用-IN-但我认为这不是解决方案

       SELECT [scod], [ecode], [scty] ,[sonm] FROM [Z_ALI].[dbo].[M_STORE]  WHERE [scod] IN ('FROMTHECHECKLIST')
我正试着这样做:

          For Each row As GridViewRow In GridView1.Rows

                If row.RowType = DataControlRowType.DataRow Then
                    Dim CheckRow As CheckBox = (TryCast(row.Cells(1).FindControl("chckSelector"), CheckBox))

                    If CheckRow.Checked Then
                        Dim scode As String = TryCast(row.Cells(2).FindControl("lblsstorecode"), Label).Text

                        Dim sql As String = "SELECT [scod], [ecode], [scty] ,[sonm] FROM [Z_ALI].[dbo].[M_STORE]  WHERE [scod] IN ('+scode+')"

                        Using cmd As New SqlCommand(sql)

                            Using dtViewing As Data.DataTable = code.GetData(cmd, "NSP", code.HRIS, "SELECT")
                                If code.err = String.Empty Then
                                    GridView4.DataSource = dtViewing
                                    GridView4.DataBind()
                                Else
                                    code.setStatus(code.err, Me.Page, "")

                                End If

                            End Using
                        End Using
                    End If
                End If
            Next
例如,这是复选框列表中的选定列表

     Checklist
  -|351530928006|
  0|351530928007|
  0|351530928008|
  0|351530928009|
  -|3515309280010|

  zero is the selected
   - is not selected
是否可以从查询中获取或迭代所有列表

SELECT scod,ecode,scty,sonm
FROM M_STORE
WHERE scod IN (Checklist(0), Checklist(1), Checklist(2)...)
或者将您的清单放在sql表中并执行此操作

SELECT scod,ecode,scty,sonm
FROM M_STORE
WHERE scod IN (SELECT scod FROM ChecklistTable)

不,检查表不在桌子上,但在检查框中,这就是为什么我说使用这个或那个,但是如果我要使用或我想说的是,如何在检查表上识别它,有两种方法。使用我提供的方法(a)或方法(b)。方法(b)需要将值放在sql表中。“+scode+”将被视为原样,因为它在单引号中,而不是这样做的方式