
Code:
[b]Local[/b] oRec [b]As[/b] [b]Dispatch[/b] [b]Local[/b] v [b]As[/b] [b]Variant[/b] [b]Local[/b] nFields [b]As[/b] [b]Long[/b] [b]Local[/b] nField [b]As[/b] [b]Long[/b] [i]' Open table.[/i] [b]If[/b] VD_ADO_Recordset_Open( $DB_CONN, "SELECT * FROM Table1", oRec ) [b]Then[/b] [i]' oRec is set [/i] [b]End[/b] [b]If[/b] [i]' Test successful recordset.[/i] [b]If[/b] [b]ObjResult[/b] [b]Then[/b] [b]MsgBox[/b] "Could not open database and/or table (" & [b]Format$[/b]( [b]ObjResult[/b] ) & ")", %MB_TASKMODAL, [b]VD_App.Title[/b] VD_ADO_Recordset_Close( oRec ) [b]Exit[/b] [b]Function[/b] [b]End[/b] [b]If[/b] [i]' Enumerate fields.[/i] nFields = VD_ADO_Recordset_Fields_GetCount( oRec ) [b]For[/b] nField = 0 [b]To[/b] nFields - 1 [b]VD_Debug_Print[/b] "Field: " & [b]Format$[/b]( nField ) & ", " & VD_ADO_Recordset_Field_GetName( oRec, nField ) [b]Next[/b] nField [i]' Add a record to Table.[/i] [i]' Table should contain 3 fields:[/i] [i]' 1) ID as long counterfield (auto)[/i] [i]' 2) Text[/i] [i]' 3) Text[/i] VD_ADO_Recordset_AddNew( oRec ) [i]' Set's fields data now, note that fields can also be valid[/i] fieldnames$ [i]' instead of the numbers being used here.[/i] VD_ADO_Recordset_FieldVariant( oRec, 1, [b]Date$[/b] ) VD_ADO_Recordset_FieldVariant( oRec, 2, [b]Time$[/b] ) VD_ADO_Recordset_Update( oRec ) [i]' Jump to last record.[/i] VD_ADO_Recordset_MoveLast( oRec ) [i]' Obtain a field again.[/i] [b]MsgBox[/b] VD_ADO_Recordset_GetFieldStr( oRec, 2 ), %MB_TASKMODAL, [b]VD_App.Title[/b] [i]' Close recordset.[/i] VD_ADO_Recordset_Close( oRec )
Comment