Microsoft KB Archive/182351

= PRB: ADO's Field ATTRIBUTE Property and adFldRowID =

Article ID: 182351

Article Last Modified on 3/2/2005

-

APPLIES TO


 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5

-



This article was previously published under Q182351



SYMPTOMS
ADO's field Attribute property will not return "adFldRowID" when checked against any data sources being accessed through the OLEDB Provider for ODBC.



CAUSE
The OLEDB Provider for ODBC, which is used by default, cannot access this information because it is not available through ODBC.



RESOLUTION
Use a native OLEDB Provider specific to the data source being used. The data source must also support a field type that maps to OLE DB's definition of a row identifier to be able to return a value of "adFldRowID."



STATUS
This behavior is by design.



MORE INFORMATION
The "adFldRowID" Attribute maps to OLEDB's DBCOLUMNFLAGS_ISROWID flag. A row that has this flag "contains a persistent row identifier that cannot be written to and has no meaningful value except to identify the row."

Using the preceding description, no column in SQL Server falls into this category. Thus, even when using a native OLEDB Provider for SQL Server, the "adFldRowID" would not be returned through the field's Attribute property. In the following sample code, if you connect to a different data source, the value of the field attribute may vary. The field Attribute value may be composed of more than one Attribute constant. For example, if the Attribute value of a specific field is 24, then it represents adFldFixed (16) + adFldUnknownUpdatable (8).

Steps to Reproduce Behavior
 Start Visual Basic. Add a Reference to the "Microsoft ActiveX Data Objects Library."  Add a command button to the form and add the following code to the click event: Private Sub Command2_Click Dim Cn As New Connection Dim rs As New Recordset Dim SQL As String

Cn.Open "DRIVER={SQL Server};SERVER=;UID=;PWD=;" SQL = "select * from pubs..jobs" rs.Open SQL, Cn        MsgBox "Name: " & rs.Fields(0).Name & vbCrLf & "Attribs: " & _ rs.Fields(0).Attributes

rs.Close Cn.Close End Sub  Notice that the attribute value is 16 which maps to adFldFixed as it appears in the message box.</ol>

<div class="references_section">