本文介绍了如何在VB.Net中插入日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
This is my query in sql server
INSERT INTO dbo.KaunselingDT (NoKaunselor, NoPerakuan, Date)VALUES('123', '456', '14 / Oktober / 2014')
And this is my Save() button in VB.Net
sql = "INSERT INTO dbo.KaunselingDT (NoKaunselor, NoPerakuan, Date)" _
& "VALUES('" & Me.txtNoKaunsDaftar.Text & "', '" & Me.txtNoAkuanAmalan.Text & "', '" & Me.lblDate.Text & "')"
How to change the lblDate to smalldatetime data type?
推荐答案
Dim formatInfo As New DateTimeFormatInfo()
formatInfo.ShortDatePattern = "dd/MM/yyyy"
formatInfo.DateSeparator = "/"
Dim objDate As DateTime = Convert.ToDateTime(Me.lblDate.Text, formatInfo)</pre>
这篇关于如何在VB.Net中插入日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!