How do I select specific columns in ADO using getstring?

When we use getstring to get data from a recordset (ADO) then it will return all columns.

If only certain columns are required, how do we change the getstring statement?

0


source to share


3 answers


You can take a step back and create a recordset with only the fields (columns) you want, like this:



strSQL="SELECT ID, FName, SName FROM Members"
rs.Open strSQL, cn

a=rs.GetString

      

+3


source


You can not. GetString returns all columns of all or a specified number of rows. You will need to go through the recordset to get the columns you want.



All this is in the documentation .

+2


source


You can also use a combination of join and getrows

myString = join(rs.getrows( , , myColumn),";")

      

  • rsGetrows returns an array containing only myColumn values
  • The connection will pass the array into a string like "value1; value2; ..."

Check the exact syntax as it was written on the fly

EDIT: unfortunately it can't be as straight forward as .getrows will return an array of 2 dimensions. Are there any functions that can extract one dimensional array from 2d? It can be easily written, right?

-1


source







All Articles