Results 1 to 2 of 2

Thread: Autonumbered, or not?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    18

    Autonumbered, or not?

    In my application I would like to able to add a column to a database (without primary key) wich has to be the primary key. this is how I do this:

    Dim cmd As New Odbc.OdbcCommand
    cmd.CommandText = "ALTER TABLE Crawford_nl ADD COLUMN " & "[Index]" & " COUNTER PRIMARY KEY"
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Connection = Me.OdbcConnection1'
    Try
    cmd.ExecuteNonQuery()
    Catch ex As Exception
    MsgBox(Err.Description)
    Me.OdbcConnection1.Close()
    Exit Sub
    End Try

    This is not a problem when the database doesn't already contain a field wich is autonumbered (because the database can not contain 2 autonumbered fields). But some databases we receive contain an autonumbered field wich is not the primary key. In that case it would be easier to just make that field primary key. Is there a way I can determine wether a field is autonumbered or not?

    Tnx in advance

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    18
    I've tried it using the attribute 'AutoIncrement' of the column object but strange enough that doesn't seem to work because I always get false, even when the column is autonumbered.
    I'm really getting sick and tired of all those bugs I've met along the way using databases in vb.net!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width