Microsoft KB Archive/181857

= PRB: RDO Run-time Error '40060': Incorrect Type for Parameter =

Article ID: 181857

Article Last Modified on 11/7/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q181857



SYMPTOMS
When assigning the value of a field from one Resultset to another (such as, rs2!FieldX = rs1!FieldY), you may get the following error:

Run-time error '40060'

Incorrect type for parameter



CAUSE
FieldY has a NULL value.



RESOLUTION
To resolve this problem, do one of the following:

  Use the following assignment expression: rs2!FieldX = rs1!FieldY.Value   Assign the value of the field to a Variant variable as an intermediate step: MyVariant = rs1!FieldY rs2!FieldX = MyVariant 



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
  Use ISQL/W or another tool to create a table using the following SQL statement: CREATE TABLE dbo.TestNull (       ID int NOT NULL,        F1 varchar (10) NULL ,        CONSTRAINT PK_TestAddNew_1__15 PRIMARY KEY  CLUSTERED          ( ID         )      )  Add a record, leaving F1 with a NULL value. You may do this in ISQL/W or VISDATA in Visual Basic.</li> In Visual Basic 5.0, create a new project.</li> Reference Microsoft Remote Data Objects 2.0.</li>  Add a command button (Command1) and the following code.

Note You must change UID and PWD to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the database. Private Sub Command1_Click Dim cn As rdoConnection, rs1 As rdoResultset, rs2 As rdoResultset rdoEngine.rdoDefaultCursorDriver = rdUseServer Set cn = rdoEngine(0).OpenConnection("", rdDriverNoPrompt, False, _         "Driver={SQL Server};Server=moonbase;uid= ;pwd= ;database=pubs") Set rs1 = cn.OpenResultset("SELECT * FROM TestNull", _         rdOpenKeyset, rdConcurValues, rdExecDirect) rs1.MoveLast Set rs2 = cn.OpenResultset("SELECT * FROM TestNull", _         rdOpenKeyset, rdConcurValues, rdExecDirect) rs2.Edit rs2!F1 = rs1!F1 rs2.Update rs1.Close rs2.Close cn.Close End Sub </li> Run the project and click the command button and the error message will appear.</li>  Change the line: rs2!F1 = rs1!F1 -to- rs2!F1 = rs1!F1.Value </li> Run the project again, and the error will not appear.</li></ol>

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Malcolm Stewart, Microsoft Corporation

Additional query words: kbVBp500 kbVBp kbWinOS98 kbDSupport kbdse kbNoKeyWord

Keywords: kbprb KB181857

-

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

© Microsoft Corporation. All rights reserved.