FillSchema Doesn't bring SQL Server Default Values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Programmer

    #1

    FillSchema Doesn't bring SQL Server Default Values

    Hi All

    Here is my problem

    I'm using a SQLDataAdapter and DataSet

    I use the method FillSchema(myDa taset, SchemaType.Sour ce)
    The problem is that when i Check the default Values of the Dataset
    i can see that the DefaultValue of the columns is system.dbnull!! !!
    But in SQL Server i have put as default values in a bigint field the '0' and
    the field is also required

    The Dataset is bound to a Datagrid and it's totaly disconected from the
    server (Custom Control)
    So because i handle the event of new row i must perform the AddRow at my
    own.
    I have capture the event and handle it for many reasons. And i can't change
    it.
    this is the code
    Dim nr As DataRow = myDataset.Table s(0).NewRow
    dsData.Tables(0 ).Rows.Add(nr)

    Then i have the crash!. And the reason is that no Default Values exists from
    the FillSchema call

    Where is my default value?????????? ????????
    How can i get them from the SQL????

    Thank you in advance.

    Kind Regards
    Dimitris


  • Programmer

    #2
    Re: FillSchema Doesn't bring SQL Server Default Values

    I know that i can get the default values of columns on syscolumns and other
    system tables.

    IN .NET In DataSet to be exact. Fill Schema should bring the default.
    Now I'm just making 2 steps and disconect from the server.
    1. FillScehama(MyD ataset, SchemaType.Sour ce)
    2. Fill(MyDataset. Tables(0))

    And the only proposion is to get a DataReader for example loon in it so i
    can get the default values?
    I have thowht that. But I don't like it.

    Isn't any implimentetion in .NET to do it without running a new select
    statement??
    Does finally the FillScehama has a bug?



    Thank you for your reply.
    Kind Regards
    Dimitris


    "Lishi Liu [MSFT]" <lishil@online. microsoft.com> wrote in message
    news:nycUBxdfFH A.2828@TK2MSFTN GXA01.phx.gbl.. .[color=blue]
    >
    >
    >
    > If you work on SQL server, you get it by
    > execute sp_MShelpcolumn s
    > for example:
    > execute sp_MShelpcolumn s 'dbo.Authors', null, 'id', 1
    >
    > The out put one row are for each column of the table dbo.Authors.
    > There is a output column "Text", that contain the the default value for
    > each column of the table(on each row).
    > Another output column "col_defnam e", contains the default object binded
    > for
    > each column of the table.
    >
    > Or you can open a table in table designner, see the defaul value or
    > binding
    > property.
    >
    > VSData team, Lishi Liu
    >
    > --------------------[color=green]
    >>Reply-To: "Programmer " <seeyou_gr@hotm ail.com>
    >>From: "Programmer " <seeyou_gr@hotm ail.com>
    >>Subject: FillSchema Doesn't bring SQL Server Default Values
    >>Date: Thu, 30 Jun 2005 15:04:14 +0300
    >>Keywords: FillSchema , SQL Default Values in FillSchema,Fill Schema Doesn't[/color]
    > bring SQL Server Default Values[color=green]
    >>Lines: 34
    >>X-Priority: 3
    >>X-MSMail-Priority: Normal
    >>X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
    >>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
    >>X-RFC2646: Format=Flowed; Original
    >>Message-ID: <eB#WEwWfFHA.37 88@tk2msftngp13 .phx.gbl>
    >>Newsgroups:[/color]
    > microsoft.publi c.dotnet.framew ork.sdk,microso ft.public.dotne t.general,micro s
    > oft.public.dotn et.languages.vb ,microsoft.publ ic.dotnet.langu ages.vb.data[color=green]
    >>NNTP-Posting-Host: 212.114.125.86
    >>Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!tk 2msftngp13.phx. gbl
    >>Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.genera l:45167[/color]
    > microsoft.publi c.dotnet.langua ges.vb:95051
    > microsoft.publi c.dotnet.langua ges.vb.data:218 5
    > microsoft.publi c.dotnet.framew ork.sdk:1779[color=green]
    >>X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb.data
    >>
    >>Hi All
    >>
    >>Here is my problem
    >>
    >>I'm using a SQLDataAdapter and DataSet
    >>
    >>I use the method FillSchema(myDa taset, SchemaType.Sour ce)
    >>The problem is that when i Check the default Values of the Dataset
    >>i can see that the DefaultValue of the columns is system.dbnull!! !!
    >>But in SQL Server i have put as default values in a bigint field the '0'[/color]
    > and[color=green]
    >>the field is also required
    >>
    >>The Dataset is bound to a Datagrid and it's totaly disconected from the
    >>server (Custom Control)
    >>So because i handle the event of new row i must perform the AddRow at my
    >>own.
    >>I have capture the event and handle it for many reasons. And i can't[/color]
    > change[color=green]
    >>it.
    >>this is the code
    >>Dim nr As DataRow = myDataset.Table s(0).NewRow
    >>dsData.Tables (0).Rows.Add(nr )
    >>
    >>Then i have the crash!. And the reason is that no Default Values exists[/color]
    > from[color=green]
    >>the FillSchema call
    >>
    >>Where is my default value?????????? ????????
    >>How can i get them from the SQL????
    >>
    >>Thank you in advance.
    >>
    >>Kind Regards
    >>Dimitris
    >>
    >>
    >>[/color]
    >[/color]


    Comment

    Working...