使用文本框时缺少日期格式? [英] Miss date format when using textbox ?

查看:110
本文介绍了使用文本框时缺少日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在使用文本框保存访问数据库日期和月份之间时,从文本框保存日期类型。

这是我的文本框格式:

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 :

tb.Text = Format(Date.Now, "dd/MM/yyyy")



reddate数据库格式:dd / MM / yyyy

保存方法:


database format for reddate : dd/MM/yyyy
saving method :

cmd.parameters.Add(New OleDbParameter("reddate", CType(tb.Text, Date)))





样本:

Textbox = 03/09/2017日/月/年

数据库= 09/03/2017月/日/年



我的尝试:



< ----------------------------- -------------------------------------------------- ------->



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

What I have tried:

<-------------------------------------------------------------------------------------->

推荐答案

可能是文本框中的格式与当前文化设置中的格式不同。尝试使用显式格式,例如

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
cmd.parameters.Add(New OleDbParameter("reddate", System.DateTime.ParseExact(tb.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);


这篇关于使用文本框时缺少日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆