ADOX, Jet OLEDB:Allow Zero Length ERROR... 
Author Message
 ADOX, Jet OLEDB:Allow Zero Length ERROR...

Hello:  I am modifying an Access database schema (adding tables) via ADOX.

This process is fairly straight forward until I try to set the JET
OLEDB:Allow Zero Length property of my text columns...

Basically VB throws a fatal memory error and dies when I try to append the
table to the tables collection of the catalog object...

*************************************************************
I.e.:

    For intC = 0 To .Columns.Count - 1
        If .Columns(intC).Type = adVarWChar Then
            .Columns(intC).Attributes = adColNullable
            .Columns(intC).Properties("Jet OLEDB:Allow Zero Length") = True
        End If
    Next
    intC = 0

catCat.Tables.Append tblTable '** Here is where the fatal memory error
occurs
**************************************************************

Any insight would be greatly appreciated...

Shannon Richards
BBA, AIT, MCP



Wed, 07 Apr 2004 04:48:06 GMT  
 ADOX, Jet OLEDB:Allow Zero Length ERROR...
FYI...I just found the answer....

It appears as though you cannot set the two properties at the same time...

.Columns(intC).Attributes = adColNullable
.Columns(intC).Properties("Jet OLEDB:Allow Zero Length") = True

I *REMOVED* the first line and the second property when set did the job of
both properties...

Thanx,
Shannon


Quote:
> Hello:  I am modifying an Access database schema (adding tables) via ADOX.

> This process is fairly straight forward until I try to set the JET
> OLEDB:Allow Zero Length property of my text columns...

> Basically VB throws a fatal memory error and dies when I try to append the
> table to the tables collection of the catalog object...

> *************************************************************
> I.e.:

>     For intC = 0 To .Columns.Count - 1
>         If .Columns(intC).Type = adVarWChar Then
>             .Columns(intC).Attributes = adColNullable
>             .Columns(intC).Properties("Jet OLEDB:Allow Zero Length") =
True
>         End If
>     Next
>     intC = 0

> catCat.Tables.Append tblTable '** Here is where the fatal memory error
> occurs
> **************************************************************

> Any insight would be greatly appreciated...

> Shannon Richards
> BBA, AIT, MCP



Wed, 07 Apr 2004 04:57:52 GMT  
 ADOX, Jet OLEDB:Allow Zero Length ERROR...


Fri, 19 Jun 1992 00:00:00 GMT  
 ADOX, Jet OLEDB:Allow Zero Length ERROR...

EUREKA - I HAVE IT!!!!!!!!!

be sure to DIM all objects WITHOUT the "New" keyword.

Dim cat As ADOX.Catalog
Dim db_TableDef As ADOX.Table
Dim db_Field As ADOX.Column

Then:

'Create your database (Catalog)
Set cat = New ADOX.Catalog
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=4;Data
Source=" & DB_DSN$

' Create your table
Set db_TableDef = New ADOX.Table
With db_TableDef
 .Name = TableName$
 .ParentCatalog = cat   <==== THIS IS IMPORTANT
End With
cat.Tables.Append db_TableDef

'Create your field(s)
Set db_Field = New ADOX.Column
'Note - the variables Field_Name$, Field_Type, etc are passed in to my
routine with aappropriate values already set.
With db_Field
 .Name = Field_Name$
      .Type = Field_Type
      .DefinedSize = Field_Size
      .ParentCatalog = cat   <==== THIS ALSO IS IMPORTANT
      .Properties("Nullable").Value = True
      .Properties("Jet OLEDB:Allow Zero Length").Value = True
End With
db_TableDef.Columns.Append db_Field
'Close your field (column)
Set db_Field = Nothing

'When you're done with all the field(s) in a table,
'Close your table
Set db_TableDef = Nothing

'When you're done with all the tables in the database,
'Close the database
Set cat = Nothing



Mon, 12 Apr 2004 23:28:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Jet OleDB: Allow zero Length property returns True

2. ADO & ADOX - Zero Length Allowed

3. ADOX: Extending a fixed length Jet string field length

4. TableDef/Set all text fields to allow zero length

5. Allow Zero Length String in a field using SQL

6. Allow Zero Length Question

7. Zero length strings not allowed

8. Create Table "Allow Zero Length"???

9. Allow Zero Length

10. 'allow zero length' not working

11. Add Allow Zero Length Property?

12. Allow Zero Length in Access DB

 

 
Powered by phpBB® Forum Software