Microsoft KB Archive/296173

= How To Use ADOX to Create an OLE Object Field in an Access Database =

Article ID: 296173

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q296173



SUMMARY
This article describes how to use ActiveX Data Objects Extensibility (ADOX) to create an OLE Object field in a Microsoft Access Database (.mdb file). You must use the adLongVarBinary constant to create the field. You do not have to specify a field size in the field definition.



Step-by-Step Example
 Create a new Standard EXE project in Visual Basic. Form1 is created by default. From the Project menu, click References. From the list of available components, click '''Microsoft ADO Ext. 2.1 for DDL and Security'''. Add a CommandButton control to Form1.  Paste the following code onto the Declarations section of Form1: Private Sub Command2_Click Set cat = New ADOX.Catalog Set tbl = New ADOX.Table cat.ActiveConnection = _ &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nwind2.mdb;&quot; tbl.Name = &quot;OleObjTable&quot; tbl.Columns.Append &quot;Column1&quot;, adInteger tbl.Columns.Append &quot;Column2&quot;, adInteger tbl.Columns.Append &quot;Column3&quot;, adVarWChar, 50 ' Please note adLongVarBinary = 205 tbl.Columns.Append &quot;MyOleObject&quot;, adLongVarBinary cat.Tables.Append tbl End Sub  Modify the cat.ActiveConnection assignment to point to a valid Microsoft Access Database file. Run the project, and click Command1. Notice that a table named OleObjTable is created in the database. When you view the table in Design Mode, the Column3 field definition is displayed as OLE Object.</ol>

<div class="references_section">