473,372 Members | 1,615 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,372 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 3256
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.