转换日期问题(Formate: - dd / MM / yyyy) [英] Problem of convert date (Formate :- dd/MM/yyyy)

查看:128
本文介绍了转换日期问题(Formate: - dd / MM / yyyy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

转换为dd / mm / yyyy的日期

ex:22-08-2015



此日期与数据库匹配因为这个日期使用绑定所有信息



Plz解决了这个问题

convert to date in dd/mm/yyyy
ex:22-08-2015

this date are match into the database Because

this date use the bind all information

Plz sloved this qutions

推荐答案

尝试:

Try:
DateTime dt;
if (DateTime.TryParseExact("22-08-2015", "dd-MM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
   {
   ...
   }


在select命令中使用Sql参数并设置用户提供的DateTime值。如果用户输入为字符串格式,则将其转换为DateTime并设置参数值。

检查有关如何为SQlDataAdapter选择命令设置参数的文档 [ ^ ]
Use Sql parameter in your select command and set the DateTime value which is provided by user. if user input is in string format, convert it to DateTime and set the parameter value.
check the documentation about how to set parameters for SQlDataAdapter select command [^]


这篇关于转换日期问题(Formate: - dd / MM / yyyy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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