从DataRow获取rowID或ObjectID [英] Get rowID or ObjectID from DataRow

查看:507
本文介绍了从DataRow获取rowID或ObjectID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上的每个人。



我有一个带有ListView的简单表格(填充了大约2800个供应商名称)。

这些名字是作为SQL select statemet的结果驻留在数据集中。

用户可以直接滚动供应商列表,直到找到他正在寻找的那个(用户抱怨这需要太长时间)或者他们可以选择ListView,然后键入供应商名称的第一个字符,ListView将选择以键入的字符开头的第一个供应商。

但是,一个字符是不够的。用户希望能够输入更多的字符并更接近供应商的名称。



为了实现这一点,我已经包含了一个快速搜索TextBox,他们可以做只需要这样。

计划是将每个字符键入并从数据集中选择一个DataRow(或dataRows)并获取Rowid / s并选择或多选ListView上的匹配项。 br $>


我遇到的巨大问题是我无法访问DataRow _Rowid(我可以在调试模式下看到它)

Morning everyone.

I have a simple form with a ListView (populated with about 2800 supplier names).
These names are resident in a dataset as a result of an SQL select statemet.
The user could simply scroll through the list of suppliers until he finds the one he is looking for (users are complaining that this takes too long) or they could select the ListView, then key in the first character of the supplier name and ListView will select the first supplier that starts with the character keyed in.
One character, however, is not enough. the users wish to be able to type more characters and get closer to the supplier name.

To achieve this I have included a "Quick Search" TextBox where they can do just that.
The plan is to take each character keyed in and select from the dataset into a DataRow (or dataRows) and get the Rowid/s and select or multiselect the matching items on the ListView.

The HUGE problem that I'm having is that I cannot seen to access the DataRow _Rowid (I can see it in debug mode)

Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Ssql = "SELECT SP_Name from Supplier Where SP_Name <> ' Select Supplier' ORDER BY SP_Name"
        da = New OleDb.OleDbDataAdapter(Ssql, cn)
        da.Fill(ds, "Suppliers")
        cn.Close()

        For x = 0 To ds.Tables("Suppliers").Rows.Count - 1
            ListView1.Items.Add(New ListViewItem(ds.Tables("Suppliers").Rows(x).Item(0).ToString))
        Next
    End Sub


    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim RowNumber As String

        RowNumber = CStr(GetRowNumbers(TextBox1.Text))

    End Sub



    Private Function GetRowNumbers(ByVal theSupplier As String) As String
        Dim Table As DataTable = ds.Tables("Suppliers")
        Dim Expression As String
        Dim FoundRows() As DataRow

        Expression = "SP_Name LIKE '" & theSupplier & "%'"

        FoundRows = Table.Select(Expression)


        If FoundRows.Count = 0 Then
            Return "Nothing Found"
        else
           Return CStr((FoundRows(0)(0)))   '<<<<< RETURN THE ds.Tables("Suppliers") row number as found in FoundRows
        End If

    End Function





任何人都可以建议怎么做。



再一次,非常感谢。



Can anyone please advise how could do this.

Once again, many thanks.

推荐答案

这篇关于从DataRow获取rowID或ObjectID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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