By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,434 Members | 2,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

Store database values in array

P: 10
Dear Techies,

I have a code which retrieves values from database
Expand|Select|Wrap|Line Numbers
  1. cmdSelect = New OleDbCommand("select fields,finesFields from trafficReport where checked LIKE 1", conn)
  2.         cmdSelectDr = cmdSelect.ExecuteReader
  4.         While cmdSelectDr.Read
  5.             MsgBox("Select " + cmdSelectDr(0) + cmdSelectDr(1) + " from fines")
  6.             'strtest = cmdSelectDr(0)
  8.             'Store all values in array here
  9.         End While

i want to store all the values in a array for further processing.

Any help would be highly appreciated

Apr 4 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,208
You could do something like this ->
Expand|Select|Wrap|Line Numbers
  1. dim ds as new dataset
  2. dim dbadap as new sqldataadapter
  3. cmdSelect = New OleDbCommand("select fields,finesFields from trafficReport where checked LIKE 1", conn)
  4. dbadap.fill(ds, "trafficReport")
So your table is stored locally in a dataset and be used again else where... I don't see any reason to really store this data into an array?
Apr 14 '09 #2

P: 10
thanks for the reply.
the reason why i need to store in array is i need for further processing.

Many thanks
Nadir Firfire
Apr 15 '09 #3

Expert 100+
P: 1,208
Well when you set it in a dataset all the values are still there just stored on the server rather than the sql db..

so after you fill the ds like i showed above later on you can do

Expand|Select|Wrap|Line Numbers
  1. for each rs as datarow in ds.tables(0).rows
  2.    msgbox(rs("traffic_id"))
  3. next
or something similiar along those lines. you can also update the dataset simply by

Expand|Select|Wrap|Line Numbers
  1. for each rs as datarow in ds.tables(0).rows
  2.  if conditions then
  3.    rs("traffic_id")=1
  4. end if
  5. next
Apr 15 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.