如何填充从数据集的数组在VB.NET [英] How to populate an array from a DataSet in VB.NET

查看:199
本文介绍了如何填充从数据集的数组在VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想填充从数据数组只使用VB.NET 2010年的特定列是否有任何code到阵列直接填充或我必须利用查询?

I'm trying to populate an array from a dataset with only a specific column using VB.NET 2010. Is there any code to populate the array directly or must I make use of a query?

推荐答案

更新

假设你想要一个String数组:

Assuming you want an array of String:

Dim arr As String() = (From myRow In ds.Tables(0).AsEnumerable
                       Select myRow.Field(Of String)("yourColumnName")).ToArray

或列表:

Dim list As List(Of String) = (From myRow In ds.Tables(0).AsEnumerable
                               Select myRow.Field(Of String)("yourColumnName")).ToList


确认将DisplayMember设置为列的名称,你希望看到:

Make sure the DisplayMember is set to the name of the column you want to see:

comboBox1.DataSource = ds.Tables(0)
comboBox1.DisplayMember= "NameOfColumn"

您可能还需要到ValueMember属性ID字段的名字从你的数据集。

You might also want to set the ValueMember property to the ID field name from your dataset.

这篇关于如何填充从数据集的数组在VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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