本文介绍了如何格式化日期并将其保存到表并使用日期查询它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我再次陷入困境,我正在为我的公司开发wince应用程序,
我的问题是,我们如何格式化日期格式日期以保存在数据库中?
和如何根据保存的日期查询该记录?
格式我想要的是dd-mmm-yyyy。
我收到错误将表达式转换为数据类型日期时间的算术溢出错误
这是我的编码。
Hi, i''m stuck again, im developing wince application for my company,
my problem is, how do we format date format date in ce to save in Database?
and How to query that record based on date saved?
format that i want is "dd-mmm-yyyy".
I got error "Arithmetic Overflow error converting expression to datatype date time"
Here my coding.
cmd = New SqlCeCommand("insert into Receiving (Id,PalletNo,Batch,Run,PCode,Qty,AddUser,AddDate) VALUES (@Id,@PalletNo,@Batch,@Run,@PCode,@Qty,@AddUser,@AddDate)", cn)
cmd.Parameters.AddWithValue("@PalletNo", txtPallet.Text)
cmd.Parameters.AddWithValue("@Batch", Trim(txtBatch.Text))
cmd.Parameters.AddWithValue("@Run", Trim(txtRun.Text))
cmd.Parameters.AddWithValue("@PCode", Trim(txtPCode.Text))
cmd.Parameters.AddWithValue("@Qty", Val(txtQty.Text))
cmd.Parameters.AddWithValue("@AddUser", txtEmpNo.Text)
cmd.Parameters.AddWithValue("@Id", (ID + 1))
cmd.Parameters.AddWithValue("@AddDate", Format(Now, "dd-mmm-yyyy"))
cmd.ExecuteNonQuery()
如何拨打保存的记录?
How to call saved record?
cn = New SqlCeConnection("Data source = \Program files\ProScan\appDatabase.sdf;persist security info= false")
cn.Open()
cmd = New SqlCeCommand("Select * From Receiving Where AddDate = @AddDate", cn)
cmd.Parameters.AddWithValue("@AddDate", Now)
sqlDAce = New SqlCeDataAdapter(cmd)
Dim rs As DataSet = New DataSet
sqlDAce.Fill(rs, "Receiving")
''没有回复记录
''请帮助并提前致谢..
''No record return
''Please help and Thanks in advance..
推荐答案
cn.Open()
cmd = New SqlCeCommand("Select * From Receiving Where AddDate = @AddDate", cn)
cmd.Parameters.AddWithValue("@AddDate", Now.ToString("dd MMMM yyyy"))
sqlDAce = New SqlCeDataAdapter(cmd)
Dim rs As DataSet = New DataSet
sqlDAce.Fill(rs, "Receiving")
cn.Close()
这篇关于如何格式化日期并将其保存到表并使用日期查询它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!