Microsoft KB Archive/245498

= BUG: MSDAIPP Provider Does Not Deny The Assignment of an Integer Value to an Array Typed Column =

Article ID: 245498

Article Last Modified on 5/8/2003

-

APPLIES TO


 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7

-



This article was previously published under Q245498



SYMPTOMS
When you assign an integer value to an Array typed field, the Microsoft Internet Publishing Provider (MSDAIPP) does not deny the assignment and the following error message occurs when you try to retrieve the field's value:

Run-time error # 13:   Type mismatch



RESOLUTION
Make sure that your data types are compatible before you assign any value to a given field.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The following Microsoft Visual Basic sample code demonstrates:


 * The creation of an array field, rec("x").


 * The assignment of an integer value (zero) to rec("x"). In this case, ActiveX Data Objects (ADO) takes the (zero) value and assigns it as the current value of the rec("x") field without returning an error message.


 * The retrieval of the rec("x") field's value, where you get a "Type mismatch" error message.

Steps to Reproduce Behavior
 Create an empty text file named Text.txt on . Start a new Visual Basic Standard EXE project. Form1 is added by default. From the Project menu, click References, and then select the "Microsoft ActiveX Data Objects 2.5 Library".  Place the following code in the General Declaration section of Form1: Private Sub Command1_Click

Dim rec As New Record

rec.Open "http:///test.txt",, adModeReadWrite, adCreateOverwrite rec.Fields.Append "x", adArray + adVariant rec("x") = Array(1, 2)

Debug.Print rec("x")(0), rec("x")(1)   ' This returns: 1, 2

rec("x") = 0                       ' <--- WRONG: Assigning an integer to an array column

Debug.Print rec("x").Type          ' This returns 8204 (stands for adArray + adVariant data-type) Debug.Print rec("x")(0)            ' Error 13 occurs here

rec.Close

End Sub  Run the code to see the error message occur.</li></ol>

<div class="references_section">