Hi Bob,
It seems that you're working on a Typed DataSet. When you are creating a
typed dataset, the default value will not be generated in the schema, you
have to add it manually. So when you add a new row to that dataset, and
exception is thrown.
To add default values to the schema, open the xsd file of your dataset.
(The xsd file is where you drag and drop the table to.) Click the column
name which you want to set a default value to. In the properties windows,
you'll see the "default" property. You can assign your default value there.
(If you cannot see the properties window, open it from the menu at View ->
Properties Window).
Does this answer your question? If anything is unclear, please feel free to
reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| From: "Bob Day" <
[email protected]>
| References: <#
[email protected]>
<
[email protected]>
| Subject: Re: Tabel Designer Default Value Field Purpose
| Date: Wed, 24 Sep 2003 11:02:50 -0500
| Lines: 1777
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: dhcp065-029-073-060.indy.rr.com 65.29.73.60
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:62030
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I am using MSDE (latest SP).
| Below is sample code that fails, attached is a screen image of the table
| definition. CD stands an instantiation of items created in Component
| Designer, DS_ for DataSet, DR for DataRow. So, given that below does not
| work, how would you use the default value in table designer?
| -------------
| CD.DS_Caller.Phones.Clear()
|
| *****I would seem to me that the DS_Caller_Base should have 'picked up'
the
| default values assigned to the table (but I know it does not)
| Dim DR As DS_Caller_Base.PhonesRow
|
| ' set DR row = to dataset we are working with
| DR = CD.DS_Caller.Phones.NewPhonesRow
|
| ' fill a few values, other values to be filled by table default values
| With DR
| .fld_FK_PIN_Table_ID = 26
| .fld_IX_PSTN_Answered_By_Number = "100"
| .fld_IX_PSTN_Ten_Digits = "200"
| .fld_IX_Type_Number = "300"
| .fld_IX_Type_Number = "400"
| End With
|
| ' add new empty row to dataset
| CD.DS_Caller.Phones.AddPhonesRow(DR)
| ***********Fails on line above message: "A first chance exception of type
| 'System.Data.NoNullAllowedException' occurred in system.data.dll.
| Additional information: Column 'fld_Type_Name' does not allow nulls."
| *********** I see why this fails. We are adding a row to the DS, not the
| DataSource, and the DS_Caller_Base never picks up the default values as
| defined in Table Designer. It seems to me that it should.
|
| rows_Updated = CD.DA_tblPhones.Update(CD.DS_Caller,
| CD.DS_Caller.Phones.TableName)
|
|
| | > Hi Bob,
| >
| > I'm following your steps and tried it on my computer. However, I could
not
| > reproduce it. The insert command accomplished without any error. Are you
| > using a SQL Server or a MSDE as database server? Would you please
provide
| > me with more information so I can deliver my assistance more quickly?
| >
| > If anything is unclear, please feel free to reply to the post.
| >
| > Kevin Yu
| > =======
| > "This posting is provided "AS IS" with no warranties, and confers no
| > rights."
| >
| > --------------------
| > | From: "Bob Day" <
[email protected]>
| > | Subject: Tabel Designer Default Value Field Purpose
| > | Date: Mon, 22 Sep 2003 18:02:36 -0500
| > | Lines: 19
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.adonet
| > | NNTP-Posting-Host: dhcp065-029-073-060.indy.rr.com 65.29.73.60
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.adonet:61857
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| > |
| > | What is the purpose of the Server Explorer, Table, Design Table,
| highlight
| > | column, Default Value field at the bottom of the screen?
| > |
| > | I thought it was to automatically place a value in the DataSource
when a
| > new
| > | row is added from a DataSet that does not have a value for that
column.
| > | Thus, you could set the table to not allow nulls, set the default
| values,
| > | fill in only the values you care about when initially adding a new
row,
| > and
| > | the defaults would fill the reset when you added the row to the
| > DataSource.
| > |
| > | But the default value is ignored, and you get an error like
| > | Column 'fld_Type_Name' does not allow nulls.
| > |
| > | even though the default for this column is set to ('') - an an empty
| > string.
| > |
| > | I cannot find anything that this Default Value field does. What is it
| > for?
| > |
| > | Bob Day
| > |
| > |
| > |
| >
|
|
|