BUG: SQL Server GetDate() Function Error: Record is DeletedLast reviewed: February 18, 1996Article ID: Q113437 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows, version 3.0
SYMPTOMSError 3167 "Record is deleted" can occur as records from the Dynaset are fetched when both of the following conditions are present:
WORKAROUNDAny one of the following three possible workarounds will work:
STATUSMicrosoft has confirmed this to be a bug in Visual Basic version 3.0 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONIf records are added directly by Visual Basic (filling the date/time field by using the Now function), there is no problem. But if the indexed date/time field is assigned by the GetDate() function, the error occurs.
Using GetDate() and a Stored Procedure that May Result in the ProblemThe GetDate() function is an intrinsic function native to Microsoft SQL Server. The most likely situation is for this to be called from within a stored procedure, which in turn is called from a Visual Basic program. The following is the SQL Server syntax used to create a stored procedure that adds records to a SQL Server table named GetDateBugTab: create proc getdatebug As declare @dt datetime, @messagestr varchar(39) select @dt=GetDate() select @messagestr = "This record added from stored proc" insert into GetDateBugTab (fDateTime, fsourceofdate) select @dt,@messagestr The structure of GetDateBugTab is reported by executing the system procedure sp_help GetDateBugTab against the SQL Server database. Results look somewhat like this:
Name Owner Type GetDateBugTab dbo user table Column_name Type Length Nulls Default_name Rule_name------------- ---------------- ------ ----- --------------- --------------- fDateTime datetime 8 1 (null) (null) fsourceofdate varchar 39 1 (null) (null) index_name index_description index_keys }ndx nonclustered, unique located on default fDateTimeThe stored procedure would be executed from Visual Basic by using code such as this: Dim db As database ' Enter the following two lines as one, single line of code:Set db = OpenDatabase("", 0, 0, "odbc;uid=sa;pwd=;DSN=sqlserver2;database=playpen2;")label1 = db.ExecuteSQL("getdatebug")
Filling the Table by Using Visual Basic Directly Causes No ProblemBy contrast, if the table is filled by Visual Basic code, no problem occurs. For example, the following code works without a problem: Dim db As database ' Enter the following two lines as one, single line of code:Set db = OpenDatabase("", 0, 0, "odbc;uid=sa;pwd=;DSN=sqlserver2;database=playpen2;")dt$ = Now ' Enter the following two lines as one, single line of code:label1 = db.ExecuteSQL("insert into GetDateBugTab (fDateTime,fsourceofdate) select '" & dt$ & "', 'This is from VB Now function'") Using SQLPASSTHROUGH Still Causes a ProblemAlternatively, the entire body of the stored procedure can be sent to the SQL Server from Visual Basic. This is because the ExecuteSQL uses the SQLPASSTHROUGH flag and sends the syntax to the SQL Server for processing. This will still cause the error, however. Dim db As database ' Enter the following two lines as one, single line of code:Set db = OpenDatabase("", 0, 0, "odbc;uid=sa;pwd=;DSN=sqlserver2;database=playpen2;")dt$ = Now ' Enter the following four lines as one, single line of code:label1 = db.ExecuteSQL("declare @dt datetime, @messagestr varchar(39)select @dt=GetDate() select @messagestr = "This record added from stored proc" insert into GetDateBugTab (fDateTime,fsourceofdate) select @dt,@messagestr") REFERENCESMore information about calling stored procedures is documented in the following Microsoft SQL manual which covers the Visual Basic Library for SQL Server: "Microsoft SQL Server Programmer's Reference for Visual Basic."
|
Additional reference words: buglist3.00 3.00 buglist3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |