tags:

views:

313

answers:

3

I have used the following way to determine if a column is auto-increment:

att = Rs1->Fields->GetItem((long)nIndex)->Attributes;
bAutoIncrement = att & adFldRowID;

But it doesn't work at all. Do anyone have good ideas about this? Thanks in advance.

A: 

PS: I am using MS Access Database.

Don't answer your own post just to add more info. Use the "edit" link on the original post instead.
Jim Garrison
A: 
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connection

Try
ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;")

ADOXCatalog.ActiveConnection = ADOConnection

Dim col As ADOX.Column
For Each col In ADOXCatalog.Tables("Table1").Columns
If col.Properties("AutoIncrement").Value = True Then
Console.WriteLine(col.Name)
End If
Next

Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ADOConnection.Close()
End Try
Treby
A: 

ADOX::PropertyPtr pAutoIncrProperty = m_pTable->Columns->Item[_variant_t(fieldInfo.m_strName)]->Properties->Item[_variant_t(_T("AutoIncrement"))];

Sheng Jiang 蒋晟
Hi, How to get m_pTable object? I am operating an exist table and not create a new table.
see Treby's reply
Sheng Jiang 蒋晟