C Sharper
C Sharper

Reputation: 8636

Get the values from dataset in vb.net

I am first time coding with vb.net and wanted to read values from dataset.

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,

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,,

Please help me.

Upvotes: 1

Views: 46102

Answers (2)

Nins Gosai
Nins Gosai

Reputation: 21

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

Upvotes: 1

NeverHopeless
NeverHopeless

Reputation: 11233

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.

Upvotes: 6

Related Questions