Results 1 to 4 of 4

Thread: Help ADO INSERT Error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    16
    I'm trying to run an INSERT INTO SQL query using the ADO recordset object. The SQL string uses lots of variables but these are correct as this procedure works fine as a SELECT query or as a SELECT INTO query.

    strAssignMonth = Format(DateAdd("m", 0, frmDates.datRFrom), "yymm")
    strSQL = "INSERT INTO QUERY SELECT EMPNO,Cstr(FRDATE) as RDATE,Cstr(LOGDATE) as CDATE,Left([LOGTIME],Len([LOGTIME])-4) as CTIME,LOGTYPE,IDENTITY,ACTCODE "
    strSQL = strSQL + "FROM LASG" & strAssignMonth & " WHERE (EMPNO='" & strEmpCode & "') "
    strSQL = strSQL + "AND (FRDATE Between {ts '" & frmDates.strRDateFrom & " 00:00:00'} "
    strSQL = strSQL + "and {d '" & frmDates.strRDateTo & "'}) AND (LOGDATE Between {d '" & frmDates.strCDateFrom & "'} "
    strSQL = strSQL + "and {d '" & frmDates.strCDateTo & "'}) AND (LOGTYPE Not In ('SPL','UPD')) "
    strSQL = strSQL + "ORDER BY EMPNO ASC, FRDATE ASC, LOGDATE ASC, LOGTIME ASC, LOGTYPE ASC;"

    rsQuery.Open strSQL, frmFront.cn, adOpenStatic, adLockReadOnly

    I keep getting the error: Operation must use an updateable query. As I say, the syntax as far as I know is fine as it works as a SELECT and SELECT INTO query, but not as a INSERT INTO.

    Any help gratefully received.

    Thanks in advance.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Umm, I have a vague idea of what all that code does, so I'm just making an observation here.

    If it says it needs an updateable query, would it help to open the recordset as read/write instead of read-only?
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    16
    Hi Harry,

    Thanks for the quick reply. I'm new to ADO so I tried using all the different properties at the end of the recordsey.open command including adLockPessimistic etc and I still got the same message.

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    try using frmFront.cn.execute strsql

    this does the insert straight into the database without using a recordset and is the way I always do inserts and should sort out your problem.


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