Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Parameterized Insert of LongVarBinary Data Type Can Return "Type Is Invalid" Error


View products that this article applies to.

Symptoms

When you attempt a parameterized insert of an SQL_LONGVARBINARY (adLongVarBinary) data type with the ActiveX Data Objects (ADO) command object, the following error message may be returned:
Type is Invalid
This problem occurs with the Microsoft Visual FoxPro driver, or with any of the Microsoft Jet Indexed Sequential Access Method (ISAM) drivers.

↑ Back to the top


Cause

The Microsoft OLE DB Provider for ODBC (MSDASQL) assumes a data type of SQL_BINARY (and not SQL_LONGVARBINARY). The Visual FoxPro and Jet ISAM drivers do not support the SQL_BINARY data type.

↑ Back to the top


Resolution

In the case of the Jet ISAM drivers, you can resolve the problem by using the native Microsoft Jet 4.0 OLE DB Provider, which does support the SQL_BINARY type. There is no known workaround for the Visual FoxPro driver.

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce Behavior

Create a data source name (DSN) named "dBaseFiles" that points to any folder, and specify "dBase 5.0" as the type. Run the following code to create a table and attempt an insert:
Private Sub Form_Load()
    Dim cn As New ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim param As ADODB.Parameter
   
    cn.Open "DSN=dBaseFiles"
    'cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data    'Source=C:\dBase;Extended Properties=dBase 5.0;Persist Security Info=False"

    cn.Execute "CREATE TABLE test (col1 oleobject)"

    cmd.ActiveConnection = cn
    cmd.CommandText = "insert into test values (?)"
    Dim arr(10) As Byte
    arr(0) = 1
    arr(1) = 2
    Set param = cmd.CreateParameter(, adLongVarBinary, adParamInput, UBound(arr) + 1, arr)
    cmd.Parameters.Append param
    cmd.Execute
    cn.Close
    Stop
    
    End
  
End Sub
				
To correct the problem, comment the line
cn.Open "DSN=dBaseFiles"
				
and uncomment the line that follows it.

↑ Back to the top


Keywords: KB264242, kbpending, kbjet, kbdbase, kbdatabase, kbbug

↑ Back to the top

Article Info
Article ID : 264242
Revision : 4
Created on : 12/5/2003
Published on : 12/5/2003
Exists online : False
Views : 455