Microsoft KB Archive/192646

= PRB: Move 0 Does Not Refresh TimeStamp and Identity Fields =

Article ID: 192646

Article Last Modified on 11/3/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q192646



SYMPTOMS
With Visual Basic and SQL Server 6.5, Move 0 does not refresh the Timestamp and Identity fields after Update/Addnew, when using the ClientBatch cursor driver.



CAUSE
A client-side cursor is being used.



RESOLUTION
Set cursordriver property to rdUseServer.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Create a test table with Timestamp field in SQL Server Pubs database. Run the following code in ISQL/W: CREATE TABLE BankTbl (Account int identity, Balance money, Stamp TimeStamp) INSERT INTO BankTbl (Balance) Values(1000) INSERT INTO BankTbl (Balance) Values(400) INSERT INTO BankTbl (Balance) Values(250) CREATE UNIQUE INDEX AcctIndex ON BankTbl(Account)  Create a Standard EXE project in Visual Basic. Form1 is created by default. Add a Reference to Microsoft Remote Data Object 2.0. Place a CommandButton on the form.  Add the following code to the General Declarations of the form to make sure that the user has appropriate permissions and values for UserId and Password: Function TSToHex(sBinRep As rdoColumn) As String Dim sBuffer As String Dim b As Integer

sBuffer = "0x" For b = 1 To 8       'Break up the binary sBuffer = sBuffer + Right$("00" & _                  Hex(AscB(MidB(sBinRep, b, 1))), 2) Next b        TSToHex = sBuffer     'Return the string End Function

Private Sub Command1_Click Dim cn As New rdoConnection Dim rs As rdoResultset Dim Timestamp As Variant Dim strConnect As String Dim strSQL As String strConnect = "Driver={SQL Server};Server=servername;Database= _        pubs;Uid=UserName;Pwd=StrongPassword"

With cn           .CursorDriver = rdUseClientBatch .Connect = strConnect .EstablishConnection End With

strSQL = "Select Account, Balance, Stamp from BankTbl" Set rs = cn.OpenResultset(strSQL, rdOpenstatic, rdConcurBatch)

Debug.Print TSToHex(rs("Stamp")) rs.Edit rs!Balance = 99 rs.BatchUpdate rs.Move 0 Debug.Print TSToHex(rs("Stamp")) End Sub </li> Press the F5 key to execute code and note the same value appears twice in the Immediate Window.</li></ol>

Additional query words: zero kbDSupport kbVBp500 kbVBp600 kbRDO200 kbdse

Keywords: kbprb KB192646

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.