make mdb field "Allow Zero Length" 
Author Message
 make mdb field "Allow Zero Length"

when creating an mdb field within VB code, i want achieve the same effect as
when in Access setting the "Allow Zero Length" property to "True"


Mon, 15 Mar 2004 06:22:16 GMT  
 make mdb field "Allow Zero Length"
As you are asking ADO, I assume you are using ADOX to create the Access
database. Then we just need to set the "Jet OLEDB:Allow Zero Length"
property of the column object.

Please reference the article HOWTO: Use ADOX to Create an AutoNumber Field
of Replication ID Field Size at
http://support.microsoft.com/support/kb/articles/Q297/9/80.ASP for sample
code regarding to this.

Hope this helps,

Robin



Mon, 15 Mar 2004 11:18:49 GMT  
 make mdb field "Allow Zero Length"
On Wed, 26 Sep 2001 15:22:16 -0700, "John A Grandy"

Quote:

>when creating an mdb field within VB code, i want achieve the same effect as
>when in Access setting the "Allow Zero Length" property to "True"

You need to use ADOX for this. This article:

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnda...>

gives you a good overview. Make sure you look in the appendix for the
farous Jet properties that can be set via ADOX. And make sure you have
Jet 4.0 SP5 installed.

Just don't duplicate the author's use of

Dim var As New Something.

Instead, when you use her sample code, change it to
Dim var As Something
Set var = New Something

The former syntax, while it works, has fallen out of favor with
experienced programmers who wish to retain control over when objects
are created and destroyed.

HTH,
Bob Barrows
Please reply to the newsgroup. My reply-to address is my "spam trap" and I don't check it very often.



Mon, 15 Mar 2004 21:05:36 GMT  
 make mdb field "Allow Zero Length"
sorry. i meant to say that i need to do this using sql.


Quote:
> As you are asking ADO, I assume you are using ADOX to create the Access
> database. Then we just need to set the "Jet OLEDB:Allow Zero Length"
> property of the column object.

> Please reference the article HOWTO: Use ADOX to Create an AutoNumber Field
> of Replication ID Field Size at
> http://support.microsoft.com/support/kb/articles/Q297/9/80.ASP for sample
> code regarding to this.

> Hope this helps,

> Robin



Tue, 16 Mar 2004 07:16:32 GMT  
 make mdb field "Allow Zero Length"
On Thu, 27 Sep 2001 16:16:32 -0700, "John A Grandy"

Quote:

>sorry. i meant to say that i need to do this using sql.

You can't. You can set the field to NOT NULL via sql, but that, of
course is different from "Allow Zero Length"

Sorry,
Bob Barrows



Tue, 16 Mar 2004 07:38:38 GMT  
 make mdb field "Allow Zero Length"
that's what i figured. oh well.


Quote:
> On Thu, 27 Sep 2001 16:16:32 -0700, "John A Grandy"

> >sorry. i meant to say that i need to do this using sql.

> You can't. You can set the field to NOT NULL via sql, but that, of
> course is different from "Allow Zero Length"

> Sorry,
> Bob Barrows



Mon, 29 Mar 2004 03:18:18 GMT  
 make mdb field "Allow Zero Length"


Fri, 19 Jun 1992 00:00:00 GMT  
 make mdb field "Allow Zero Length"
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

Hope it works for you too.



Mon, 12 Apr 2004 23:36:53 GMT  
 
 [ 8 post ] 

 Relevant Pages 

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

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

3. Allow Zero Length String in a field using SQL

4. How To Change Field Property To "Allow Zero Length=Yes" After Make-Table Query?

5. "Zero" supression in calculation fields

6. "Globlal" field getting set to zero

7. How to Create field with "Allow Zero Length=Yes" with VB5 Code ?

8. Setting Allow Zero Length = "yes" in Code

9. Setting "Allow Zero Length" with ADOX?

10. ADO Column.Properties("Jet OLEDB:Allow Zero Length")

11. Column.Properties("Set OLEDB:Allow Zero Length") = true

12. Setting "Allow Zero Length" with ADO/ADOX?

 

 
Powered by phpBB® Forum Software