Results 1 to 7 of 7

Thread: OpenRecordset versus SQL INSERT INTO

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    OpenRecordset versus SQL INSERT INTO

    I have several questions:

    1) Why do I generate an error when attempting to add a record using VB6 OpenRecordset realtime code -- when at the same time -- I am viewing the same Table in Access (as Administrator)
    2) Will adding a Record using SQL INSERT INTO instead of OpenRecordset stop this error,
    and if so, why?
    3) The fastest (or best) way to add a record using DAO and why
    ================================

    Code:
    OpenRecordset method:
    
    Set rs = DaoDb.OpenRecordset(strTBLName)
    With rs
    
    .Index = "PrimaryKey"
    .Seek "=", dtmHistDateTime
    
    If .NoMatch Then
    .AddNew
    !fldOne = dtmTime
    !fldTwo = sngData
    .Update
    End If
    
    .Close
    End With
    ==========================
    Code:
    SQL Param INSERT INTO method
    
    strParam = "PARAMETERS [pOne] DATETIME, [pTwo] SINGLE; "
    strSQL = strParam
    strSQL = strSQL & "INSERT INTO " & strTBLName
    strSQL = strSQL & " (fldOne, fldTwo)"
    strSQL = strSQL & " VALUES (pOne, pTwo);"
    Last edited by dw85745; Sep 29th, 2010 at 08:48 PM.

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