954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Retrieve Data from a dataset

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 AsString = "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

Tellie
Newbie Poster
11 posts since Apr 2004
Reputation Points: 7
Solved Threads: 0
 

Ok now what I have done to this is:

Dim sQuery AsString = "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 AsString

permID = mySet.GetXml.ToString()

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

Is this a correct approach?

Tellie
Newbie Poster
11 posts since Apr 2004
Reputation Points: 7
Solved Threads: 0
 

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?!

srikkanthan
Light Poster
27 posts since May 2004
Reputation Points: 42
Solved Threads: 0
 

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

injunraiv
Newbie Poster
1 post since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

For i = 0 To mySet.Tables(0).Rows.Count - 1
PERMISSION_BUTTON_ID = ds.Tables(0).Rows(i).Item(0)
Next

also you can do it in so many other ways . go throught the follwoing link.

http://vb.net-informations.com/dataset/vb.net-ado.net-dataset-tutorial.htm

lemo.

chan_lemo
Newbie Poster
17 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

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

Gayan Wijeratne
Newbie Poster
4 posts since Nov 2008
Reputation Points: 10
Solved Threads: 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

Rogachev
Light Poster
44 posts since Nov 2008
Reputation Points: 11
Solved Threads: 9
 

i would select column in dataset

vbahlam
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

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.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You