Results 1 to 2 of 2

Thread: Insert Fields into a table

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Posts
    124

    Insert Fields into a table

    I am using ADO accessing the Access 2000 database. How do I insert a field into a table ?
    Thanks.

  2. #2
    nullus
    Guest

    Smile

    two ways

    1. Use a recordset

    VB Code:
    1. Dim rstAddRecord As ADODB.Recordset
    2. Set rstAddRecord = New ADODB.Recordset
    3.  
    4. rstAddRecord.Open "Table1", con, adOpenKeySet, adLockOptimistic
    5. rstAddRecord.AddNew
    6.   rstAddRecord!Field1 = "blah"
    7.   rstAddRecord!Field2 = "dfgffg"
    8.   'etc.
    9. rstAddRecord.Update
    10. rstAddRecord.Close

    2. Use SQL

    VB Code:
    1. Dim strSQL As String
    2.  
    3. strSQL = "insert into table1 (Field1, Field2, Field3) values ('blah', 'dfgfdg', 'ertretr')"
    4.  
    5. con.Execute strSQL

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