0

如果我将 xml 数据类型列加载到数据表中,那么我可以对其执行 xml 查询吗?SQL Server 支持 .exist、.value 对 xml 列的查询。我正在尝试对数据表进行此类查询。

下面是代码的一部分,它显示了我在哪里出错。

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        Dim timDiff As Double
        Dim iter1 As Integer

        TextBox1.Text &= Button15.Text & vbNewLine & "      Iterations: " & TextBox2.Text & vbNewLine
        timDiff = DateAndTime.Timer
        Dim SqlAdapter As New SqlDataAdapter

        Dim strTemp As String
        Dim iRow As Integer

        Dim rConn As New SqlConnection("data source=pc91\sqlexpress;user id=admin;password=abc;initial catalog=Checklists;connect timeout=2000;")
        rConn.Open()

        SqlAdapter = New SqlDataAdapter
        sDataSet = New DataSet
        sqldatatable = Nothing


        SqlAdapter.SelectCommand = New SqlCommand("select * from DesignChanges", rConn)
        SqlAdapter.Fill(sDataSet, "tmpTable")
        sqldatatable = sDataSet.Tables("tmpTable")

        For iter1 = 1 To Val(TextBox2.Text)
            Try
                For iRow = 0 To sqldatatable.Rows.Count - 1
                    strTemp = sqldatatable.Rows(iRow).Item("AllotedTo").ToString
                Next iRow
            Catch ex As Exception
                MsgBox(ex.ToString & Space(10) & Err.Description)
            End Try
        Next
        rConn.Close()


        SqlAdapter.Dispose()
        rConn.Dispose()

        sDataSet = Nothing
        SqlAdapter = Nothing
        rConn = Nothing
        timDiff = DateAndTime.Timer - timDiff
        TextBox1.Text &= "      Total Time Taken: " & timDiff & vbNewLine
    End Sub



    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        bs.DataSource = sqldatatable
        DataGridView1.DataSource = bs

    End Sub

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click

       bs.Filter = "[UserApproval].exist ('/Root/Row[User=''xyz'']') =1"

    End Sub
End Class

在上面的代码中,错误类似于“表达式包含未定义的函数调用 UserApproval.exist()”。对于行 bs.Filter = "[UserApproval].exist ('/Root/Row[User=''xyz'']') =1" 。

如果我使用 .value 函数,则会出现错误,因为“表达式包含未定义的函数调用 UserApproval.value()。”

但相同的功能适用于 sql server 的 SQL 查询。

4

1 回答 1

-1

是的你可以。你读过这个吗?什么样的查询效果不好?

于 2013-08-04T14:58:40.247 回答