|
-
Apr 9th, 2000, 08:16 PM
#1
Thread Starter
Junior Member
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.
-
Apr 9th, 2000, 08:25 PM
#2
Frenzied Member
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."
-
Apr 9th, 2000, 08:39 PM
#3
Thread Starter
Junior Member
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.
-
Apr 9th, 2000, 10:27 PM
#4
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|