谁能解决,Visual Studio 2010从access2007中提取日期,显示出错。
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
con = New OleDbConnection(strCon)
con.Open()
cmd.Connection = con
cmd.CommandText = "select * from person where [ID] = val('" & TextBox1.Text & "') "
dr = cmd.ExecuteReader()
If dr.Read() Then
TextBox2.Text = Format(dr(1), "yyyy-m-d")
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
Label5.Text = Format(dr(1), "yyyy-m-d")
MsgBox(Format(dr(1), "yyyy-m-d"))
End If
dr.Close()
dr = Nothing
con.Close()
con = Nothing
End Sub
不论在文本框,标签,提示框中显示都是:如2012-0-12,月数只显示为0.