Make a array form Database

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I select a single field from a table of database, like:
Select distinct EmployeeID from Employee.

Have there any convenient to throw the result of select items into a static
array?
or I must iterate throw the select result to add selected item into a
dynamic array?
 
DataReader.GetValues ?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
distinct EmployeeID sounds redundant, if not wrong, but if your getting more
than one distinct ID back in the resultset, your gonna have to iterate over
the rows.

As for a dynamic array, you'll have to read the value of each row into an
ArrayList and convert that to an array of the type you need.
DataReader.GetValues() will return an object array of the current row, since
your only dealing with 1 field that doesn't benefit you any.

Ron
 
Ad,

You mean something as
\\\
dim dt as new datatable
dim da as new xxxdataadapter(theDistinctString,theConnection)
da.fill(dt)
dim count as integer = dt.rows.count 'gives the amount of id's
dim firstID as string = dt.rows(0)(0).ToString 'gives the first id
///

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top