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



The information in this article applies to:

  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • ActiveX Data Objects (ADO) 2.1
  • ActiveX Data Objects (ADO) 2.5

This article was previously published under Q264242

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.

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.

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.

STATUS

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

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.

Modification Type:MajorLast Reviewed:12/5/2003
Keywords:kbbug kbDatabase kbDBase kbJET kbpending KB264242