Visual Studio 2010 中 DateTimePicker1.Value与DateTimePicker1.Text的区别? 20
程序如下:PublicClassFrmBTPTrendDimmyConnAsOleDb.OleDbConnectionDimmyOraDataAdapterAsOleDb...
程序如下:
Public Class FrmBTPTrend
Dim myConn As OleDb.OleDbConnection
Dim myOraDataAdapter As OleDb.OleDbDataAdapter
Dim series(13) As C1.Win.C1Chart.ChartDataSeries
Private Sub refreshdata()
Dim sqlstring1 As String, sqlstring2 As String
myConn = New OleDb.OleDbConnection(connString)
sqlstring1 = " select * from MDATA1 where dtrq<=to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss') and dtrq>=to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss')-4/24 ORDER BY DTRQ ASC"
myOraDataAdapter = New OleDb.OleDbDataAdapter(sqlstring1, myConn)
Dim myDataSet As DataSet = New DataSet()
myOraDataAdapter.Fill(myDataSet, "MDATA1")
If myDataSet.Tables("MDATA1").Rows.Count < 1 Then
sqlstring2 = " select (to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'若将DateTimePicker1.Value全部改成DateTimePicker1.Text 则:
'sqlstring2为" select (' ','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'因而不能查出日期。不知为何?
myOraDataAdapter = New OleDb.OleDbDataAdapter(sqlstring2, myConn)
myOraDataAdapter.Fill(myDataSet, "DUAL")
Label_DT.Text = Format(myDataSet.Tables("DUAL").Rows(0)(0), "yyyy-MM-dd HH:mm:ss") & "---" & Format(DateTimePicker1.Value, "yyyy-MM-dd HH:mm:ss")
Return
End If
End Sub
End Class
'若将DateTimePicker1.Value全部改成DateTimePicker1.Text 则:
'sqlstring2为" select (' ','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'因而不能查出日期。不知为何? 展开
Public Class FrmBTPTrend
Dim myConn As OleDb.OleDbConnection
Dim myOraDataAdapter As OleDb.OleDbDataAdapter
Dim series(13) As C1.Win.C1Chart.ChartDataSeries
Private Sub refreshdata()
Dim sqlstring1 As String, sqlstring2 As String
myConn = New OleDb.OleDbConnection(connString)
sqlstring1 = " select * from MDATA1 where dtrq<=to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss') and dtrq>=to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss')-4/24 ORDER BY DTRQ ASC"
myOraDataAdapter = New OleDb.OleDbDataAdapter(sqlstring1, myConn)
Dim myDataSet As DataSet = New DataSet()
myOraDataAdapter.Fill(myDataSet, "MDATA1")
If myDataSet.Tables("MDATA1").Rows.Count < 1 Then
sqlstring2 = " select (to_date('" & DateTimePicker1.Value & "','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'若将DateTimePicker1.Value全部改成DateTimePicker1.Text 则:
'sqlstring2为" select (' ','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'因而不能查出日期。不知为何?
myOraDataAdapter = New OleDb.OleDbDataAdapter(sqlstring2, myConn)
myOraDataAdapter.Fill(myDataSet, "DUAL")
Label_DT.Text = Format(myDataSet.Tables("DUAL").Rows(0)(0), "yyyy-MM-dd HH:mm:ss") & "---" & Format(DateTimePicker1.Value, "yyyy-MM-dd HH:mm:ss")
Return
End If
End Sub
End Class
'若将DateTimePicker1.Value全部改成DateTimePicker1.Text 则:
'sqlstring2为" select (' ','yyyy-mm-dd hh24:mi:ss')-4/24) from dual"
'因而不能查出日期。不知为何? 展开
2个回答
展开全部
这个看Msdn就好了
DateTimePicker.Text 属性
此属性返回的字符串等效于具有相应格式或应用的自定义格式的 Value 属性。 例如,如果将 Value 属性设置为 06/01/2001 12:00:00 AM,同时将 CustomFormat 属性设置为“dddd, MMMM dd, yyyy”,则 Text 属性值为“Friday, June 01, 2001”。
DateTimePicker.Text 属性
此属性返回的字符串等效于具有相应格式或应用的自定义格式的 Value 属性。 例如,如果将 Value 属性设置为 06/01/2001 12:00:00 AM,同时将 CustomFormat 属性设置为“dddd, MMMM dd, yyyy”,则 Text 属性值为“Friday, June 01, 2001”。
追问
Msdn中没有关于本问题代码中出现的现象的解释。
追答
你sql里的to_date怎么没了?
你应该是说用Value属性可以获取到值,而Text获取不到值吧?
没有碰到这种问题,建议你修改下CustomFormat 的属性,并调试看看Text的内容到底是多少
实在不行,MessageBox.Show(xxx.Text)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询