Results 1 to 9 of 9

Thread: STUMPED with ADO Fields Collection

  1. #1

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322

    STUMPED with ADO Fields Collection

    HELP...

    I am stumped at how to append a new field to a recordset and then after that sending the new recordset with the new added field back to Access Using ADO2.0 and JET

    Could anybody give me any pointers ? I am stumped at especially which part I have to close the recordset and set the activeconnection to Nothing
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    You want to add a new field to a table?
    -= a peet post =-

  3. #3

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322
    Yes Peet,

    I want to add a new field to an Access Table BUT not using native SQL alter Table statements. I want to do it using the recordset object and fields collection of ADO...For my MCSD case study.

    Thanks
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    oh.. I think u have to use ADOX, in order to do that.

    Add a reference to the Microsoft ADO Extensions for DDL and Security (ADOX).

    I'll digup a sample for u....
    -= a peet post =-

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    This sample show u how to create a new db and adding a table to it.

    VB Code:
    1. Option Explicit
    2. Dim cat As ADOX.Catalog
    3. Dim tbl As ADOX.Table
    4.  
    5. Private Sub Command1_Click()
    6.     Set cat = New ADOX.Catalog
    7.     Set tbl = New ADOX.Table
    8.  
    9.     ' create the table
    10.     cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\newDB.mdb"
    11.    
    12.     With tbl
    13.       .Name = "TestTable"
    14.       ' Create fields and append them to the
    15.       ' Columns collection of the new Table object.
    16.       With .Columns
    17.          .Append "ID COLUMN"
    18.          .Append "SetName", adVarWChar, 255
    19.          .Append "SetVal", adVarWChar, 255
    20.          .Append "Description", adVarWChar, 255
    21.       End With
    22.    End With
    23.    
    24.    ' Add the new Table to the Tables collection of the database.
    25.    cat.Tables.Append tbl
    26.    
    27.    Set cat = Nothing
    28.    Set tbl = Nothing
    29.    
    30. End Sub

    hope this can get u started
    -= a peet post =-

  6. #6

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322

    Hi Peet

    I really appreciate the help you have given me peet

    The thing is I need to append a new field using ADODB...Is that possible at all ?
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    don't think so, but I'm not 100 % sure though... but I'v never seen it done.

    anyone else have any input ?
    -= a peet post =-

  8. #8
    Lively Member
    Join Date
    Aug 2000
    Location
    Bristol, UK
    Posts
    86
    This can't be done with ADO. You have to use ADOX or DAO


    Cenobite

  9. #9

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322
    THanks Cenobite,

    I guess I have to stick with the commandText property of the ADO Command Object to append fields to a database using native SQL Alter Keyword statements for now.
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

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