943,547 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 130846
  • VB.NET RSS
Apr 27th, 2004
0

Retrieve Data from a dataset

Expand Post »
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
Similar Threads
Reputation Points: 7
Solved Threads: 0
Newbie Poster
Tellie is offline Offline
11 posts
since Apr 2004
Apr 27th, 2004
1

Re: Retrieve Data from a dataset

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?
Reputation Points: 7
Solved Threads: 0
Newbie Poster
Tellie is offline Offline
11 posts
since Apr 2004
May 10th, 2004
0

Re: Retrieve Data from a dataset

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?!
Reputation Points: 42
Solved Threads: 0
Light Poster
srikkanthan is offline Offline
27 posts
since May 2004
Oct 18th, 2007
0

Re: Retrieve Data from a dataset

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

VB.NET Syntax (Toggle Plain Text)
  1. da.Fill(EmployeeData)
  2. OleDbConnection1.Close()
  3.  
  4. Dim row As Data.DataRow
  5. Dim count As Integer = EmployeeData.Rows.Count
  6. Dim i As Integer = 0
  7.  
  8. For i = 0 To count - 1
  9. '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...
Last edited by injunraiv; Oct 18th, 2007 at 10:28 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
injunraiv is offline Offline
1 posts
since Oct 2007
Oct 16th, 2008
0

Re: Retrieve Data from a dataset

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/datas...t-tutorial.htm

lemo.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chan_lemo is offline Offline
17 posts
since Oct 2008
Nov 27th, 2008
0

Re: Retrieve Data from a dataset

Click to Expand / Collapse  Quote originally posted by Tellie ...
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 ...................
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Gayan Wijeratne is offline Offline
4 posts
since Nov 2008
Nov 28th, 2008
0

Re: Retrieve Data from a dataset

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
Reputation Points: 11
Solved Threads: 9
Light Poster
Rogachev is offline Offline
44 posts
since Nov 2008
Apr 14th, 2010
0
Re: Retrieve Data from a dataset
i would select column in dataset
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vbahlam is offline Offline
3 posts
since Apr 2010
Apr 14th, 2010
1
Re: Retrieve Data from a 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.
Last edited by adatapost; Apr 14th, 2010 at 7:38 am.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in VB.NET Forum Timeline: Access Denied On File Download
Next Thread in VB.NET Forum Timeline: Combobox selected value





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC