在MS Accessdatabase中保存日期时间格式 [英] save the date time format in MS Accessdatabase

查看:86
本文介绍了在MS Accessdatabase中保存日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 sql =  插入Tb_SCH_Faculty_Details([Faculty_Code],[Faculty_Name], [Mobile_No],[Entered_date],[Active],[Allocated_Hours]) +  
('
+ txt_Faccode.Text.ToUpper()+ ',' + Txt_Facname.Text + ',' + txt_Mobile.Text + ', + string .Format( {0:dd-MMM-yyyy},DateTime.Now)+ ,'A', + txt_Hrs.Text + ;





当我运行上述查询错误时显示如下;





无一个或多个必需参数的值。



显示上述错误?



我上面的插入代码有什么问题。



请帮帮我。

解决方案

我相信你需要用#字符包装日期:



  string  .Format( #{0}#,DateTime。 Now.ToString(  dd-MMM-yyyy))


sql = "insert into Tb_SCH_Faculty_Details  ([Faculty_Code], [Faculty_Name], [Mobile_No],[Entered_date],[Active],[Allocated_Hours]) " + " values
('" + txt_Faccode.Text.ToUpper() + "','" + Txt_Facname.Text + "','" + txt_Mobile.Text + "', " + string.Format("{0:dd-MMM-yyyy}", DateTime.Now) + ",'A'," + txt_Hrs.Text + ")";



when i run the above query error shows as follows;


No Value given for one or more required parametres.

shows the above error?

what is the problem in my above insert code.

please help me.

解决方案

I believe you need to wrap your date in # characters:

string.Format ( "#{0}#", DateTime.Now.ToString ( "dd-MMM-yyyy" ) )


这篇关于在MS Accessdatabase中保存日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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