473,385 Members | 1,930 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,385 software developers and data experts.

Column DefaultValue (Very easy question)

nev
251 100+
I use VB 2005 Pro v8.0.50727.42

I use datadesigner to manage my dataset. In my form, I dragged a datagridview of one of my tables. It has a date column. In the property pane for the date column, there is a defaultvalue which is set to <dbnull>. How do I set it so that the defaultvalue is the current date?

I tried changing <dbnull> to...
1. <Date> 'does not do the job.
2. <Date(Now())> 'no luck
3. <Now()> 'still nothing

What should I put in the defaultvalue property so that the column's defaultvalue will be the date today? Or is this possible?
Oct 31 '07 #1
7 2647
debasisdas
8,127 Expert 4TB
Question moved to .NET Forum.
Oct 31 '07 #2
nev
251 100+
I use VB 2005 Pro v8.0.50727.42

I use datadesigner to manage my dataset. In my form, I dragged a datagridview of one of my tables. It has a date column. In the property pane for the date column, there is a defaultvalue which is set to <dbnull>. How do I set it so that the defaultvalue is the current date?

I tried changing <dbnull> to...
1. <Date> 'does not do the job.
2. <Date(Now())> 'no luck
3. <Now()> 'still nothing

What should I put in the defaultvalue property so that the column's defaultvalue will be the date today? Or is this possible?
Does anyone know how to do this? In design-time?
Oct 31 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
Does anyone know how to do this? In design-time?
DateTime.Now is the .Net way of getting the current date.

So guess you should try that.
I have upto now havent had to set default values to non numeric columns...so at the moment im just guessing
Oct 31 '07 #4
nev
251 100+
My column is a stringtype. I tried to place DateTime.Now in the defaultvalue property @ design-time. When I run the program and place my cursor in the newrow of the datagridview, it displays "DateTime.Now".
Oct 31 '07 #5
nev
251 100+
My column is a stringtype. I tried to place DateTime.Now in the defaultvalue property @ design-time. When I run the program and place my cursor in the newrow of the datagridview, it displays "DateTime.Now".
Update!

I changed the column's datatype in the mysql database as well as in the datadesigner in vb 2005 into datetime. This time when I place datetime.now in the defaultvalue property, it errors 'Property value is invalid. The string was not recognized as a valid DateTime.'
Oct 31 '07 #6
Shashi Sadasivan
1,435 Expert 1GB
Update!

I changed the column's datatype in the mysql database as well as in the datadesigner in vb 2005 into datetime. This time when I place datetime.now in the defaultvalue property, it errors 'Property value is invalid. The string was not recognized as a valid DateTime.'
is this a windows form based application or asp .net?

I have a work around fix for this for windows forms.
Oct 31 '07 #7
nev
251 100+
is this a windows form based application or asp .net?

I have a work around fix for this for windows forms.
It is a winform based app. I can do it through code. But I wanna learn how to do it @ design-time.

Through code:
dataset.table.column.defaultvalue = datetime.now.toshortdatestring

Through property pane @ design-time:
defaultvalue | ???
Oct 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
1
by: Darryn Ross | last post by:
Hi, I am trying to display a long integer value from my access table in a Datagrid with a custom style applied to it and the value is not coming through correct?? database value = 0.00000 %...
17
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5...
2
by: Larry Bird | last post by:
I have a datatable that was created within a dataset. I dynamically add columns to the table as I add data. Previously added rows probably did not have data for the column that is being added. ...
0
by: Carlo, MCP | last post by:
Good morning, sorry for the lenght of the code, but it's six months that I've this problem. The following code is an extreme simplification of the original code, that is much more complex. The...
9
by: PeterWellington | last post by:
I have a column in a data table that stores enum values and assigns a default value: Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday When I...
10
by: tony | last post by:
Hello!! I have some demo programs written in C# and they have this construction "" see below. I haven't seen this before so what does it mean ? public bool ShowDropDownButtons { get {...
5
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
0
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...

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.