|
-
Dec 21st, 2009, 02:43 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Recordset not updating
I have a routine that populates a dataset (SQL SERVER 2000). Then, it goes back to delete duplicates.
The code that populates the database runs fine. The code that looks for sduplicates give me a [3251] Current record Does Not Support Updatign message. As mentioned, it does support updating, as the previous routines was able to add records.
So here if the code up the line where the rrror occurs (at the rs1.update command):
Code:
'===========================
Set rs1 = New ADODB.Recordset
'===========================
sql = "SELECT * FROM TMPCOMPNEEDED ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]"
rs1.Open sql, CnxnTempSQL, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs1.BOF And Not rs1.EOF Then
Do
If UNPRTD = "" Then
UNPRTD = rs1![UNPRTD]
LINE = rs1![LINE]
JOB = rs1![JOB]
REMBAL = rs1![REMBAL]
ONHAND = rs1![ONHAND]
LOT = rs1![LOT]
Else
If Trim(rs1![UNPRTD]) = Trim(UNPRTD) And rs1![LINE] = LINE And rs1![LOT] = LOT And rs1![ONHAND] = ONHAND Then
rs1![DROPTHIS] = "X"
rs1.Update
Else
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2009, 02:52 PM
#2
Lively Member
Re: Recordset not updating
I've never used ADODB for SQL but in all my applications to update an MS Access database it would require the following:
vb Code:
rs1.Edit rs1![DROPTHIS] = "X" rs1.Update
I'm probably gonna be wrong lol, but that's my input.
-
Dec 21st, 2009, 02:55 PM
#3
Thread Starter
PowerPoster
Re: Recordset not updating
It doesn't like that bit of code.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2009, 03:01 PM
#4
Re: Recordset not updating
Try like this:
code Code:
'===========================
Set rs1 = New ADODB.Recordset
'===========================
sql = "SELECT * FROM TMPCOMPNEEDED ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]"
rs1.Open sql, CnxnTempSQL, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs1.BOF And Not rs1.EOF Then
rs1.EDIT
Do
If UNPRTD = "" Then
UNPRTD = rs1![UNPRTD]
LINE = rs1![LINE]
JOB = rs1![JOB]
REMBAL = rs1![REMBAL]
ONHAND = rs1![ONHAND]
LOT = rs1![LOT]
Else
If Trim(rs1![UNPRTD]) = Trim(UNPRTD) And rs1![LINE] = LINE And rs1![LOT] = LOT And rs1![ONHAND] = ONHAND Then
rs1![DROPTHIS] = "X"
rs1.Update
Else
Missing stuff here
rs1.MoveNext
WEnd
rs1.Update
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 21st, 2009, 03:04 PM
#5
Thread Starter
PowerPoster
Re: Recordset not updating
It does like .edit at all, nowhere.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2009, 03:16 PM
#6
Thread Starter
PowerPoster
Re: Recordset not updating
When I get rid of this "ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]", I do not get the error message. Making headway.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2009, 03:19 PM
#7
Lively Member
Re: Recordset not updating
Must be because it's SQL, actually I don't use .edit and .update to remove a record from MS Access databases, I've always just used .delete. Must be totally different when accessing SQL.
-
Dec 21st, 2009, 03:19 PM
#8
Thread Starter
PowerPoster
Re: Recordset not updating
I created an index on the recordset and it worked. Go figure.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2009, 03:26 PM
#9
Lively Member
Re: [RESOLVED] Recordset not updating
Lol at least it's working, sorry I couldn't help.
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
|