Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
on page load

VdateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";


on save click

cmd.Parameters.AddWithValue("Date", VdateTimePicker1.Value);


give error cannot insert null value

datatype in DB is datetime

tyhx in advance
Posted
Updated 21-Jan-15 22:34pm
v2
Comments
DamithSL 22-Jan-15 4:36am    
update the question with full insert code
Karthik_Mahalingam 22-Jan-15 4:40am    
keep a break point on this line " cmd.Parameters.AddWithValue("Date", VdateTimePicker1.Value);" and check the value property, that it contains any value.
Master Vinu 22-Jan-15 4:45am    
yes value is contain
Karthik_Mahalingam 22-Jan-15 4:53am    
what is the value ? post here
User-8621695 22-Jan-15 4:41am    
You can use like this ---> datetime.now.tostring(""). Pass type in .ToString() it will work.

1 solution

cmd.Parameters.AddWithValue("Date", VdateTimePicker1.Value.ToString("MM/dd/yyyy hh:mm tt"));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900