Re: determine whether a field is identity column




"cutecode" <cutecode@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8AC8539D-4F82-4B5F-B479-50E6D300D260@xxxxxxxxxxxxxxxx
how to determine whether a field is identity column using ADO?

Thanks

until someone who actually knows comes along <g>
here's a sample from the net...source unknown.. that might give some hint

Sub PrimaryKeyX()

Dim catNorthwind As New ADOX.Catalog
Dim tblNew As New ADOX.Table
Dim idxNew As New ADOX.Index
Dim idxLoop As New ADOX.Index
Dim colLoop As New ADOX.Column

' Connect the catalog
catNorthwind.ActiveConnection = "data source=c:\Program Files\" & _
"Microsoft Office\Office\Samples\Northwind.mdb;"

' Name new table
tblNew.Name = "NewTable"

' Append a numeric and a text field to new table.
tblNew.Columns.Append "NumField", adInteger, 20
tblNew.Columns.Append "TextField", adVarWChar, 20

' Append new Primary Key index on NumField column
' to new table
idxNew.Name = "NumIndex"
idxNew.Columns.Append "NumField"
idxNew.PrimaryKey = True
idxNew.Unique = True
tblNew.Indexes.Append idxNew

' Append an index on Textfield to new table.
' Note the different technique: Specifying index and
' column name as parameters of the Append method
tblNew.Indexes.Append "TextIndex", "TextField"

' Append the new table
catNorthwind.Tables.Append tblNew

With tblNew

Debug.Print tblNew.Indexes.Count & " Indexes in " & _
tblNew.Name & " Table"

' Enumerate Indexes collection.
For Each idxLoop In .Indexes

With idxLoop
Debug.Print "Index " & .Name
Debug.Print " Primary key = " & .PrimaryKey
Debug.Print " Unique = " & .Unique

' Enumerate Columns collection of each Index
' object.
Debug.Print " Columns"
For Each colLoop In .Columns
Debug.Print " " & colLoop.Name
Next colLoop

End With

Next idxLoop

End With

' Delete new table as this is a demonstration
catNorthwind.Tables.Delete tblNew.Name
Set catNorthwind = Nothing

End Sub


.



Relevant Pages

  • Re: Parsing / " characters
    ... have the rest of the code to append the ... - JCL inserts that string at the start of every program, ... >>the code associated with that program - in exact order, ... >>Dim db As Database, tdf As TableDef ...
    (microsoft.public.access.externaldata)
  • Re: Fastest way to append text to a TextBox
    ... What's the fastest way to append text to a TextBox? ... CPU and, even if I limit the TextBox to just 30KB of text, it takes over ... Private Sub AppendText(ByVal sText As String) ... Dim iLen As Integer = .Text.Length + sText.Length ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Inserting a line at the beginning of a Text file
    ... Dim intTarget As Integer ... Dim strSource As String ... > The next thing that happens is that I open that text file up to add a> variable to it, however I can only either overwrite the file using the> Output method therefore losing the original table that was exported> and the file only contains the variable, or I can Append to the text> file, however append adds the variable as the last line in the file> and I need the variable to be the first line in the file. ...
    (microsoft.public.access.externaldata)
  • DOM CreateElement?
    ... Sub Page_Load ... Dim xmlDoc As New XmlDocument ... Dim eltProducts1 As XmlElement = xmlDoc.CreateElement ... AppendData.xml, I have used 2 different variables to append the 2 sets ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: File Append Row by Cell value
    ... Dim vFile As String ... Dim vFound As Boolean ... Can you append rows and can they be comma seperated? ...
    (microsoft.public.excel.programming)