473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Default value not being populated in dataset

Bob
I have a CreatedOn field , datetime, which has GetDate() as the default
value in SQL server 2000 table. When I create a new record in the table
itself in enterprise manager, the field gets populated OK, but when I try to
create a new record with a Microsoft datagridview control, I notice that the
datecreated value does not get created. It looks as if the datagridview
insert statements overrides the default value and prevent the default
defined in the table to get written.

Any ideas on how to overcome this? I've looked in the datagridview controls
properties and the dataset properties for this table and don't find anything
simple to let me ensure that on an insert my default value defined in the
table is the one saved.

Any help would be appreciated.

Bob
Jun 26 '06 #1
2 3258
Bob,

AFAIK is the defaultvalue for the DataBase never set for the datatable (for
sure not in version 1.x). Maybe you find that strange, but Net should work
on more databases than only those from Microsoft.

You can however create in your datatables as well a default.

http://msdn2.microsoft.com/en-US/lib...aultvalue.aspx

Maybe is that the solution for your problem.

Cor

"Bob" <bd*****@sgiims.com> schreef in bericht
news:uj**************@TK2MSFTNGP04.phx.gbl...
I have a CreatedOn field , datetime, which has GetDate() as the default
value in SQL server 2000 table. When I create a new record in the table
itself in enterprise manager, the field gets populated OK, but when I try
to create a new record with a Microsoft datagridview control, I notice that
the datecreated value does not get created. It looks as if the datagridview
insert statements overrides the default value and prevent the default
defined in the table to get written.

Any ideas on how to overcome this? I've looked in the datagridview
controls properties and the dataset properties for this table and don't
find anything simple to let me ensure that on an insert my default value
defined in the table is the one saved.

Any help would be appreciated.

Bob

Jun 26 '06 #2
Bob
Its a solution but it goes against the most basic rules of using RDBMS that
is, make the database do all the work that you can have it do, so that your
default values and validations are centralized in one location and you DO
NOT do that in your application code.
The fact that .NET works with many different databases is a weak excuse for
not having completed its development right.
If there is this problem that is known there should be a property in the
datatableAdapters or in the dataset definitions, somewhere where it makes
sense and is easily accessible to the developper, to force the default value
of a new column in a dataset or table adapter. There isn't. That a table
adapter should overwrite the default values of the database is stupid in the
first place. The .Net framework could look in the metadata of the tables
being used and find if there is a default value for a column, if there is it
should just not include these fields in the autogenerated insert statement.
Then you would not be getting a null value overwriting your database
defaults.
Just another example of halfbaked reasoning by Microsoft, Oh well. Maybe
sometime in the future they'll get it right and put the emphasis where its
due. On the reliability of the data, instead of on all the unecessary
glitter of so-called userfriendly interfaces.

Anyways, Thanks Cor

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
Bob,

AFAIK is the defaultvalue for the DataBase never set for the datatable
(for sure not in version 1.x). Maybe you find that strange, but Net should
work on more databases than only those from Microsoft.

You can however create in your datatables as well a default.

http://msdn2.microsoft.com/en-US/lib...aultvalue.aspx

Maybe is that the solution for your problem.

Cor

"Bob" <bd*****@sgiims.com> schreef in bericht
news:uj**************@TK2MSFTNGP04.phx.gbl...
I have a CreatedOn field , datetime, which has GetDate() as the default
value in SQL server 2000 table. When I create a new record in the table
itself in enterprise manager, the field gets populated OK, but when I try
to create a new record with a Microsoft datagridview control, I notice
that the datecreated value does not get created. It looks as if the
datagridview insert statements overrides the default value and prevent the
default defined in the table to get written.

Any ideas on how to overcome this? I've looked in the datagridview
controls properties and the dataset properties for this table and don't
find anything simple to let me ensure that on an insert my default value
defined in the table is the one saved.

Any help would be appreciated.

Bob


Jun 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Gage | last post by:
I am trying to populate DataSets with results from SQL queries. Usually, to that end, the DataSet.Fill method works fine. If however the table includes a character field populated with a space,...
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
7
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking...
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
1
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
4
by: cwilliams01 | last post by:
Hello I am new to VB.NET, so sorry if this is really obvious. I have written the following code to fill my dataset from a stored procedure requiring 1 paramter input (from a SQL database). The...
1
by: Mark Baldwin | last post by:
Steven Thanks for your reply, however the typed datasets are defined in the web service and there seems to way to open the partial class code window - double clicking on the design surface does...
7
by: =?Utf-8?B?Tmljb2xhcw==?= | last post by:
Yes another question about databindings. All my controls are have databindings and works fine for navigating, adding, deleting etc. What I want is when I create a New record have those fields...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.