J
Jamie Collins
Code to reproduce:
Sub Test()
Const PATH As String = "" & _
"C:\"
Const FILENAME_JET As String = "" & _
"New_Jet_DB.mdb"
Const CONN_STRING_JET As String = "" & _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=<PATH><FILENAME>"
' Build connection string
Dim strConJet As String
strConJet = CONN_STRING_JET
strConJet = Replace(strConJet, "<PATH>", PATH)
strConJet = Replace(strConJet, "<FILENAME>", FILENAME_JET)
' Create DB
Dim Cat As Object
Set Cat = CreateObject("ADOX.Catalog")
Cat.Create strConJet
With Cat.ActiveConnection
' Create table
.Execute "CREATE TABLE Test1 (MyBooleanCol YESNO NOT NULL DEFAULT
True)"
' Get schema info
Dim oRs As Object
Set oRs = .OpenSchema(4, Array(Null, Null, "Test1", "MyBooleanCol"))
End With
With oRs
' Print relevant info
Debug.Print "Is nullable=" & !IS_NULLABLE
Debug.Print "Has default=" & !COLUMN_HASDEFAULT; ""
Debug.Print "Default value=" & !COLUMN_DEFAULT
Debug.Print "Character max length=" & !CHARACTER_MAXIMUM_LENGTH
.Close
End With
End Sub
Results:
Is nullable=False
Has default=True
Default value=True
Character max length=2
Why does my Boolean column have a character max length at all? Why is
it two?
I can code around this apparent anomaly, of course, but I wondered is
there some significance I haven't considered?
Thanks,
Jamie.
--
Sub Test()
Const PATH As String = "" & _
"C:\"
Const FILENAME_JET As String = "" & _
"New_Jet_DB.mdb"
Const CONN_STRING_JET As String = "" & _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=<PATH><FILENAME>"
' Build connection string
Dim strConJet As String
strConJet = CONN_STRING_JET
strConJet = Replace(strConJet, "<PATH>", PATH)
strConJet = Replace(strConJet, "<FILENAME>", FILENAME_JET)
' Create DB
Dim Cat As Object
Set Cat = CreateObject("ADOX.Catalog")
Cat.Create strConJet
With Cat.ActiveConnection
' Create table
.Execute "CREATE TABLE Test1 (MyBooleanCol YESNO NOT NULL DEFAULT
True)"
' Get schema info
Dim oRs As Object
Set oRs = .OpenSchema(4, Array(Null, Null, "Test1", "MyBooleanCol"))
End With
With oRs
' Print relevant info
Debug.Print "Is nullable=" & !IS_NULLABLE
Debug.Print "Has default=" & !COLUMN_HASDEFAULT; ""
Debug.Print "Default value=" & !COLUMN_DEFAULT
Debug.Print "Character max length=" & !CHARACTER_MAXIMUM_LENGTH
.Close
End With
End Sub
Results:
Is nullable=False
Has default=True
Default value=True
Character max length=2
Why does my Boolean column have a character max length at all? Why is
it two?
I can code around this apparent anomaly, of course, but I wondered is
there some significance I haven't considered?
Thanks,
Jamie.
--