Click here to Skip to main content
16,012,821 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want save date type from textbox when saving on access database the date miss between day and month with textbox.
this is my textbox format :
VB
tb.Text = Format(Date.Now, "dd/MM/yyyy")

database format for reddate : dd/MM/yyyy
saving method :
VB
cmd.parameters.Add(New OleDbParameter("reddate", CType(tb.Text, Date)))


SAMPLE :
Textbox = 03/09/2017 day/month/year
Database= 09/03/2017 month/day/year

What I have tried:

<-------------------------------------------------------------------------------------->
Posted
Updated 3-Sep-17 3:40am

1 solution

Could it be that the format in the text box differs from the format in your current culture settings. Try using explicit formatting, for example
C#
cmd.parameters.Add(New OleDbParameter("reddate", System.DateTime.ParseExact(tb.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
 
Share this answer
 
Comments
[no name] 3-Sep-17 10:43am    
compensated
Wendelius 3-Sep-17 14:00pm    
Thanks!
Khabibb Mubarakk 8-Sep-17 6:35am    
hey bro how to save currentdate to access db from vb.net..
i using
 datetime.now.tostring("dd/MM/yyyy hh:mm:ss") 

but going to mis day and month again.. must by parse first?

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