PRB: ADOX Error -2147217859 "Type Is Invalid" When You Append a Table to a Catalog (266302)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q266302

SYMPTOMS

When you use ADOX to append a new table to an ADOX catalog, you may receive the following error message:
Runtime error: '-2147217859 (80040e3d)':
Type is invalid.

CAUSE

This problem occurs because providers can accept only recognized data types for the columns in the table. Each provider is different and specific to the database format in which it is stored.

RESOLUTION

To resolve this problem, use a data type that the provider supports. The following list includes the data types that each provider supports:

ConstantValueJet 3.51Jet 4.0SQL 7.0
adBinary128YesYesYes
adBoolean11YesYesYes
adChar129YesNoYes
adCurrency6YesYesYes
adDate7YesYesNo
adDouble5YesYesYes
adGUID72YesYesYes
adInteger3YesYesYes
adLongVarBinary205YesYesYes
adLongVarChar201YesNoYes
adLongVarWChar203NoYesYes
adNumeric131NoYes (with info)*Yes (with info)*
adSingle4YesYesYes
adSmallInt2YesYesYes
adUnsignedTinyInt17YesYesYes
adVarBinary204YesYesYes
adVarChar200YesNoYes
adVarWChar202NoYesYes
adWChar130NoYesYes
adDBTimeStamp135NoNoYes

* When you use the adNumeric data type with Microsoft Jet 4.0 and Microsoft SQL Server 7.0, you must set precision.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Visual Basic, create a new Standard EXE project. Form1 is created by default.
  2. From the Project menu, click References, and then click Microsoft ADO Ext. 2.1 for DDL and Security.
  3. Place a CommandButton control (Command1) onto Form1.
  4. Paste the following code onto the Declarations section of Form1:
    Private Sub Command1_Click()
    
       Set cat = New ADOX.Catalog
       Set tbl = New ADOX.Table
       cat.ActiveConnection = _
          "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Nwind.mdb;"
       tbl.Name = "TestTable"
       tbl.Columns.Append "ValidColumn", adInteger
       tbl.Columns.Append "InvalidColumn", adDBTimeStamp
       cat.Tables.Append tbl
    End Sub
    					
  5. Modify the "cat.ActiveConnection" property so that it points to a valid Microsoft Access database file.
  6. Run the project, and press Command1. You receive the above-mentioned error because the Jet provider does not support the adDBTimeStamp data type.

REFERENCES

For more information and code samples about the supported data types for the Jet provider, see the following MSDN white paper:

"Migrating from DAO to ADO: Defining and Retrieving a Database's Schema"
http://msdn.microsoft.com/library/techart/daotoadoupdate.htm

For more information about the supported data types for the SQL Server OLE DB Provider, see the following Microsoft Web site:

Modification Type:MajorLast Reviewed:8/23/2001
Keywords:kbDSupport kbJET kbprb KB266302