Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Why DataColumn.DefaultValue is null

Why DataColumn.DefaultValue is null

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
3 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad Safwat
    wrote on last edited by
    #1

    I'm using OleDBCommand.ExecuteReader(CommandBehavior.KeyInfo) Now, in the result DataTable, columns that have default values set in database, appears with DefaultValue property equal DBNull.Value I tried everything; every CommandBehavior, dealing with SQl Server or MS Access, using DataAdapter instead of DataReader,... but no way :(((( Pleaaaaaaaase help

    A 2 Replies Last reply
    0
    • A Ahmad Safwat

      I'm using OleDBCommand.ExecuteReader(CommandBehavior.KeyInfo) Now, in the result DataTable, columns that have default values set in database, appears with DefaultValue property equal DBNull.Value I tried everything; every CommandBehavior, dealing with SQl Server or MS Access, using DataAdapter instead of DataReader,... but no way :(((( Pleaaaaaaaase help

      A Offline
      A Offline
      Ahmad Safwat
      wrote on last edited by
      #2

      Hi all, I got it use OleDbConnection.GetOleDbSchemaTable Method ... don't ask me whyyyyyy Microsoft does that anyway.. here is an example: DataTable SchemaTable = connection.GetOleDbSchemaTable( OleDbSchemaGuid.Columns, new object[] { null, null, "Employees", null }); you will find a column in "SchemaTable" datatable with name "Column_Default" Good Luck

      1 Reply Last reply
      0
      • A Ahmad Safwat

        I'm using OleDBCommand.ExecuteReader(CommandBehavior.KeyInfo) Now, in the result DataTable, columns that have default values set in database, appears with DefaultValue property equal DBNull.Value I tried everything; every CommandBehavior, dealing with SQl Server or MS Access, using DataAdapter instead of DataReader,... but no way :(((( Pleaaaaaaaase help

        A Offline
        A Offline
        Ahmad Safwat
        wrote on last edited by
        #3

        Now I have a new problem... The retrieved value for Default Value is not in a usable format, it is retrieved as it is stored in database for example: In SQL Server, nvarchar field's default value is stored as follow ('value') or (N'value') In MS Access, Text field's default value is stored as follow "value" Now, how can I get the value without quotes regardless of database type

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups