简体   繁体   English

从vb.net中的数据集中获取值

[英]Get the values from dataset in vb.net

I am first time coding with vb.net and wanted to read values from dataset. 我是第一次使用vb.net进行编码,想从数据集中读取值。

For that i have coded as follows, but not working: 为此,我编写了如下代码,但无法正常工作:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '------------------------------Load Name------------------'

        Try
            Dim strcon As String = ConfigurationManager.ConnectionStrings("ConnStringDb").ConnectionString
            Dim i As Integer
            Dim con As New SqlConnection(strcon)

            da = New SqlDataAdapter("select empName from empMaster_VB", con)
            ds = New DataSet()
            da.Fill(ds)
            For(i=0;i<ds.



        Catch ex As Exception

        End Try
  End Sub

as we take values from dataset in C# i tried it with VB (From for loop) as, 当我们从C#中的数据集中获取值时,我尝试使用VB(从for循环)进行测试,

for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{

  int someVar=int.parse(ds.Tables[0].Rows[i][0].toString());

}

but its not working in vb.net as i coded above,, 但是它不能在我上面编码的vb.net中工作,

Please help me. 请帮我。

You can try like this: 您可以这样尝试:

For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
    Dim someVar As Integer = Integer.parse(ds.Tables(0).Rows(i)(0).toString())
Next

You can use online converter to resolve this issue. 您可以使用在线转换器来解决此问题。

dim strDay As String
strDay = dsDataSet.dtDataTable.Rows(intRowIndex).ToString

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM