how to create an autoincrement field in an unbound ADO recordset ? 
Author Message
 how to create an autoincrement field in an unbound ADO recordset ?

Hi,

I tried to create a recordset with no connecton to a database :

Global RS As New Recordset
Public Sub InitKonfig()
    Set RS = Nothing
    RS.Fields.Append "ID", adInteger, , adFldKeyColumn + adFldRowID
    RS.Fields.Append "TemplateName", adChar, 100, adFldUpdatable
    RS.Fields.Append "TemplateMode", adInteger, , adFldUpdatable
    RS.Fields.Append "FieldName", adChar, 100, adFldUpdatable
    RS.CursorType = adOpenKeyset
    RS.LockType = adLockOptimistic
    RS.Open
End Sub

can someone tell me how to make the field 'ID' autoincrement ??

TIA Oliver



Sun, 24 Oct 2004 01:23:09 GMT  
 how to create an autoincrement field in an unbound ADO recordset ?
Hi,

You cannot create Autoincrement field in disconnected
recordset. But what you can do is to define it as Integer
and declare your recordset variable with events. In that
case you can catch RecordsetChangeComplete event from
recordset, to catch adding of new record into it. Inside
that event you can assign new integer value to your field

Val
Microsoft MVP

Quote:
>-----Original Message-----
>Hi,

>I tried to create a recordset with no connecton to a
database :

>Global RS As New Recordset
>Public Sub InitKonfig()
>    Set RS = Nothing
>    RS.Fields.Append "ID", adInteger, , adFldKeyColumn +
adFldRowID
>    RS.Fields.Append "TemplateName", adChar, 100,
adFldUpdatable
>    RS.Fields.Append "TemplateMode", adInteger, ,
adFldUpdatable
>    RS.Fields.Append "FieldName", adChar, 100,
adFldUpdatable
>    RS.CursorType = adOpenKeyset
>    RS.LockType = adLockOptimistic
>    RS.Open
>End Sub

>can someone tell me how to make the field 'ID'
autoincrement ??

>TIA Oliver

>.



Sun, 24 Oct 2004 02:04:42 GMT  
 how to create an autoincrement field in an unbound ADO recordset ?
Thanks, this should help.



Quote:
> Hi,

> You cannot create Autoincrement field in disconnected
> recordset. But what you can do is to define it as Integer

...........


Sun, 24 Oct 2004 03:30:33 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Autoincrement fields and ADO.NET

2. ADOX autoincrement field when creating database

3. ADO and autoincrement fields in Jet

4. ADO Problem - Autoincrement field

5. Creating AutoIncrement Field using code

6. ADO: retrieve autoincrement Fields

7. Need to create random autoincrement field

8. ADO: Retrieve autoincrement field

9. Error 3001 when creating adLongVarWChar or adLongVarBinary field dynamically in ADO recordset

10. Unbound fields and 'creatable recordset'

11. How create a recordset unbound of the tables

12. ADO Recordset unbound to any Database?

 

 
Powered by phpBB® Forum Software