Article ID: 185823
Article Last Modified on 5/17/2007
Sub TestRequiredStatus()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.recordset
Dim f As ADODB.Field
' Open a Microsoft Access database using NW97 ODBC data source.
conn.Open "NW97", "admin", ""
'Uncomment the following lines to test with the Jet OLE DB Provider 3.51
'conn.Open "Provider=Microsoft.Jet.OLEDB.3.51;" & _
' "Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb"
'Uncomment the following lines to test with the Jet OLE DB Provider 4.0
'conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
' "Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb"
' Create a table with a nullable and non-nullable field.
conn.Execute "CREATE TABLE AdoNullableTest " & _
"(NonNullableField TEXT NOT NULL, NullableField TEXT)"
' Open a recordset on the new table.
rs.Open "AdoNullableTest", conn, adOpenStatic, _
adLockReadOnly, adCmdTable
' Print the status of the adFldIsNullable flag for each field.
For Each f In rs.Fields
Debug.Print f.Name & " is Nullable? " & _
IIf(f.Attributes And adFldIsNullable, "YES", "NO")
Next f
rs.Close
conn.Close
End Sub
Keywords: kbbug kbdatabase kbdriver kbjet kbmdacnosweep kbpending kbprovider KB185823