Re: Number of columns in an ADO recordset
- From: "Dag Sunde" <dag@xxxxxx>
- Date: 3 Mar 2006 16:17:39 +0100
"Iwanow" <kpalak@xxxxx> wrote in message
news:1141395680.093652.200620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Pardon me for a newbie question.
I access first column of an ADO recordset object by calling rs(0), the
second column - by rs(1), and so on... This works well as long as I now
number of columns in the recordset.
A problem may occur when I process data brought from an SQL source with
"select * ..." query. If number of columns in the SQL DB changes, the
recordset my crash with a runtime error 3265 (attempting to access
non-existing part of a recordset).
Is there any way to retrive number of columns from a recently populated
recordset? And how to distinguish them if they are reordered (maybe
some column label)?
You might want to take a look at what VB's Object Browser can tell you
about the RecordSet object...
Dim fld as ADODB.Field
' Number of columns
Debug.Print rs.Fields.Count
' Detailed data for each column
For Each fld In rs.Fields
Debug.Print fld.ActualSize
Debug.Print fld.Attributes
Debug.Print fld.DataFormat
Debug.Print fld.DefinedSize
Debug.Print fld.Name
Debug.Print fld.NumericScale
Debug.Print fld.OriginalValue
Debug.Print fld.Precision
Debug.Print fld.Properties
Debug.Print fld.Status
Debug.Print fld.Type
Debug.Print fld.UnderlyingValue
Debug.Print fld.Value
Next fld
--
Dag.
.
- References:
- Number of columns in an ADO recordset
- From: Iwanow
- Number of columns in an ADO recordset
- Prev by Date: Re: Does a certain file exist?
- Next by Date: Problem in database updation through Adapter in VB.Net...
- Previous by thread: Number of columns in an ADO recordset
- Next by thread: Problem in database updation through Adapter in VB.Net...
- Index(es):
Relevant Pages
|