Hi All

I have created a dataset and from this I want to retrieve values of a column into a variable. How can I do this?

This is the code:

Dim sQuery As String = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where ROLE_ID = 1"

Response.Write(sQuery)

Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(sQuery, connectionString)

Dim mySet As DataSet = New DataSet

myAdapter.Fill(mySet, "ALC_SECURITY_PERMISSION")

From the above code I need to retrieve all the values of PERMISSION_BUTTON_ID retrieved from the Select statement inot a variable.

Please help

Ok now what I have done to this is:

Dim sQuery As String = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where ROLE_ID = 1"

'Response.Write(sQuery)

Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(sQuery, connectionString)

Dim mySet As DataSet = New DataSet

myAdapter.Fill(mySet, "ALC_SECURITY_PERMISSION")

Dim permID As String

permID = mySet.GetXml.ToString()

But now I am not sure how to retrieve values from this?

Is this a correct approach?

I am not sure what exactly you want to do... Obviously by looping through
mySet.Tables(0).Rows(i)("PERMISSION_BUTTON_ID") you can get all button ids... right?!

I'm not sure this will help, as I'm a beginner at this language myself, but here's code I figured out last night for my program...

da.Fill(EmployeeData)
                OleDbConnection1.Close()

                Dim row As Data.DataRow
                Dim count As Integer = EmployeeData.Rows.Count
                Dim i As Integer = 0

                For i = 0 To count - 1
                    'vSeq = EmployeeData.Rows(i).Item("Seq")

What we're doing in this snippet is filling my 'EmployeeData' dataset, setting up a counter to loop through all the records, and putting the value of the column "Seq" into my vSeq variable.

Hope this helped...

Hi All

I have created a dataset and from this I want to retrieve values of a column into a variable. How can I do this?

This is the code:

Dim sQuery As String = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where ROLE_ID = 1"

Response.Write(sQuery)

Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(sQuery, connectionString)

Dim mySet As DataSet = New DataSet

myAdapter.Fill(mySet, "ALC_SECURITY_PERMISSION")

From the above code I need to retrieve all the values of PERMISSION_BUTTON_ID retrieved from the Select statement inot a variable.

Please help

suppose your dataset is -ds

you can see your data

msgbox(ds.Tables(0).rows(0).itemarray(0))

this is the first row / first column data

but you shuld have a atleast one row in the data set.

Other wise it should check with


if ds.tables(0).rows.count > 0 ...................

Hi,

Maybe this code can help you.

for each _row as DataRow in mySet.Tables("ALC_SECURITY_PERMISSION").Rows
msgbox( _row.Item("PERMISSION_BUTTON_ID").ToString())
Next

i would select column in dataset

Hi.

We appreciate your help. Have you ever noticed that the current thread is six years old? Please do not resurrect old threads and have a look at forum rules. Please read before posting again - http://www.daniweb.com/forums/thread78223.html

Thread Closed.

commented: close++ -> rep++ :) +20
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.