473,769 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3281
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******** ******@TK2MSFTN GP04.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
datatableAdapte rs 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******** ******@TK2MSFTN GP04.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******** ******@TK2MSFTN GP04.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
datagridvie w 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
6631
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, the DataSet throws an exception. I assume that the restriction is because of the DataSet's use of XML. I tried setting the XMLDataDocument's PreserveWhiteSpace property, but to no avail. The error message I receive is: The DataSet Xml...
1
15751
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 columns to show some of the columns. Few of the columns have textboxes to make them available for editing. I am trying to update the dataset all at once using one update button. Here is my code... (for simplicity I have only listed one of the...
7
23530
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 for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
1
1870
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 columns to show some of the columns. Few of the columns have textboxes to make them available for editing. I am trying to update the dataset all at once using one update button. Here is my code... (for simplicity I have only listed one of the...
1
9388
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 in the dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. Is there a default cell value property or something similar for the asp.net gridview control. So if no data is...
4
6140
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 extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub Page_Load(..........) Dim dSet As DataSet Dim sqlConn As SqlConnection
4
1976
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 Stored Procedure is quite lengthy including a number of inner joins. The Dataset is used to populate a combobox on a form. I get the combobox to be populated by the dataset correctly based on my query selection. When the combobox selected item...
1
1785
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 nothing. I can do this in the client for a client specific dataset, but not in the web service. -- Best regards Mark Baldwin
7
1619
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 pre-fill with some value stored in my user.setting so the user doesn't have to re-type evrything all the time. Should be so straight forward that I don't get it! The fields are not getting populated with those values.
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.