Programatically checking Allows Null property of a column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bmcallister
    New Member
    • Oct 2007
    • 1

    Programatically checking Allows Null property of a column

    SQL such as the following returns the Allows Null property of a column in SQL Server:
    [code=sql]
    select is_nullable from information_sch ema.columns where
    table_name = 'TheTableName' and
    column_name = 'TheColumnName'
    [/code]
    I need to do the same in MS Access and have tried the following:
    [code=sql]
    select ColumnProperty( Object_ID('TheT ableName'), 'TheColumnName' ,
    'AllowsNull')[/code]

    I get the error: 'Undefined function ColumnProperty in expression'.

    I am programming in Delphi (using a TADOQuery) with an Access97 database.

    Any clues would be much appreciated.
    Last edited by pbmods; Oct 10 '07, 03:23 AM. Reason: Added CODE tags.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Maybe the nice folks in mySQL can be of assistance. To the folks in mySQL, let me know if I should have moved it elsewhere ;-)

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, bmcallister. Welcome to TSDN!

      Please use CODE tags when posting source code:

      [CODE=sq l]
      SQL code goes here.
      [/CODE]

      I'm going to go ahead and move this thread to the Access forum, where our resident Experts will be better able to help you out.

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        Hi, there.

        I'm not sure JetSQL supports something like you are expecting.
        Here is example of how it may be done in VBA via Access object model.
        Code:
        Public Function GetFieldRequiredProperty(txtTable As String, _
                                                 txtField As String) As Boolean
        
            GetFieldRequiredProperty = _
                CurrentDb.TableDefs(txtTable).Fields(txtField).Required
        
        End Function

        Comment

        Working...