从数据表中检索数据 [英] retrieve data from a datatable
本文介绍了从数据表中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用单行代码从AutoCompleteStringCollection中的数据表中检索数据?
在vb中是否有使用linq的方法或其他任何方法?
我使用这种方法
进行了检索
How can I retrieve data from a datatable in an AutoCompleteStringCollection using a single line of code?
Is there a method using linq or any other method in vb ?
I retrieved it using this method,
Dim result = From o In Item.AsEnumerable() Select o.Field(Of String)("columnname")
Dim values() As String = result.ToArray()
txtGroup.AutoCompleteSource = AutoCompleteSource.CustomSource
txtGroup.AutoCompleteCustomSource = values
但这给了我说
的错误
类型字符串的一维数组"的值不能转换为"System.Windows.Forms.AutoCompleteStringCollection".
如何解决?
提前感谢
but it gives me error saying
Value of type ''1-dimensional array of String'' cannot be converted to ''System.Windows.Forms.AutoCompleteStringCollection''.
How can it be solved ?
Thanx in advance
推荐答案
使用txtGroup.AutoCompleteSource.AddRange()像这样:
use txtGroup.AutoCompleteSource.AddRange() like so:
Dim result = From o In Item.AsEnumerable() Select o.Field(Of String)("columnname")
Dim values() As String = result.ToArray()
txtGroup.AutoCompleteSource = AutoCompleteSource.CustomSource
txtGroup.AutoCompleteCustomSource.addrange(values)
希望有帮助,
雷
Hope that helps,
Ray
这篇关于从数据表中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文