Click here to Skip to main content
16,020,677 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all

I'm developing a desk top application in VB.net.

When I try to store the date in Database in SQL it is not storing the date I given in DateTimePicker which is 21/08/2010 & in the date base storing the date of 01/01/1900.

When I try to store the value in a string i.e xdate and see that it shows the correct date as under


xdate = DTdocdt.Value.Date

Message show the date as "21/08/2010".

But store the date in data bases is 01/01/1900.

I try to store in SQL DATETIME type.

Pl guide about the error.

Jatinder gupta
Posted

'01/01/1900' is default minimum date. Surely you are missing something somewhere when trying to save in database.

Try SQL Profilier to check what is being passed to DB for storage.
Use debugger to trace value of the date at every possible place while passing it through DB.

Doing the above two can tell you actual reason of it and then you can try to resolve it.
 
Share this answer
 
Comments
Jatinder Gupta 22-Aug-10 7:10am    
Dear Sir,

As I explained that I try to see the value even just before to Store in Database with Message which shows correct date. But store only 01/01/1900.
Sandeep Mewara 22-Aug-10 7:20am    
Did you checked SQL Profiler?
Jatinder Gupta 23-Aug-10 3:54am    
Dear sir,

Pl guide for me as I'm unaware about SQL Profiler.

Kindly give me step for that.

Regards,

Jatinder gupta.
Sandeep Mewara 23-Aug-10 4:23am    
Google for SQL Profiler. Its a SQL tool that will tell you what is being executed on a particular DB. Thus, in it you will be able to see what query is being passed to SQL for insertion. Though, I must say 99% times, debugging too can tell that - so either debug and see what was the value passed in query to DB then profiler.
Are you passing the selected date to the variable that is stored?

It seems the obvious missing link.

When you select a date in DateTimePicker, it is held within that control, but needs to be exposed to the rest of the program.

Hard to be more concise without seeing the relevent bit of code.
 
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