
Problem with ADO and SQl Server on adding a new record in a table
Hi folks,
I have a problem with ADO 2.5 / ASP / SQL Server 7.0.
I have this table on my DB:
CREATE TABLE [dbo].[T_MESSAGGI] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[NOME] [varchar] (20) NULL ,
[COGNOME] [varchar] (30) NULL ,
[ID_THREAD] [int] NOT NULL ,
[DATA] [smalldatetime] NULL
) ON [PRIMARY]
I need to insert a new record in the database, and if the variable thread_id
is 0, i want set the field
[ID_THREAD] equals to the [ID] of the same record.
With my code, at the end of a mail, sometime, ADO send me this error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested
operation requires a current record.
If I stop the code at the REM all work fine.
Thanks for any idea or suggestion and sorry for may bad english
--
Lorenzo Soncini
Delta Informatica S.p.a.
I have tried this code:
dTimeStamp = Now()
Set objRSInsert = Server.CreateObject("ADODB.RecordSet")
objRSInsert.Open "T_MESSAGGI", cnnForumDC, adOpenDynamic,
adLockPessimistic,adCmdTable
objRSInsert.AddNew
objRSInsert.Fields("DATA") = dTimeStamp
objRSInsert.Fields("NOME") = forum_id
objRSInsert.Fields("COGNOME") = thread_id
objRSInsert.Fields("ID_THREAD") = thread_id
objRSInsert.Update
REM ---
objRSInsert.Requery
iNewMessageId = objRSInsert.Fields("ID")
If thread_id = 0 Then
objRSInsert.Update "ID_THREAD",iNewMessageId
End If
REM ---
objRSInsert.Close
Set objRSInsert = Nothing