如何使用maskedtextbox在访问数据库中插入空日期

编程入门 行业动态 更新时间:2024-10-25 18:30:01
本文介绍了如何使用maskedtextbox在访问数据库中插入空日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

hi all, How to insert null date in access db using maskedtextboxi want to insert null date into access database for that im using masked textbox same way i need to update suppose user enter blank cheque_date but he want to update cheque_date so he can be update cheque_date also after retrieving data i want update code also for this

我尝试过: b $ b 插入代码:

What I have tried: Insert Code :

if (txtmaskchequedate.Text == "") { cmd.Parameters.AddWithValue("@Cheque_Date", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Cheque_Date", txtmaskchequedate.Text); }

推荐答案

我设置格式:短路到访问数据库并运行跟随代码,在两者中成功执行方式:maskedtextfield空或填充 i set format :shortdate into access database and run follow code its executed successfully in both way either maskedtextfield empty or filled DateTime chequeDate; var value = (object)DBNull.Value; if (DateTime.TryParseExact(txtmaskchequedate.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out chequeDate)) { value = chequeDate; } cmd.Parameters.AddWithValue("@Cheque_Date", value);

更多推荐

如何使用maskedtextbox在访问数据库中插入空日期

本文发布于:2023-10-25 22:23:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528280.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   如何使用   日期   maskedtextbox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!