我在文本框中的表单中显示数据库中的日期,但数据库中日期的格式为mm/dd/yyyy
如何以yyyy-mm-dd
格式显示。
可以将我的日期格式编辑为mm/dd/yyyy
吗?
这是我的代码:
Dim search As String = String.Empty
search &= "select * from stocks "
search &= "where build_number=@build"
If ebuildnumber.Text = "" Then
MsgBox("Please Input Build Number Before Searching")
End If
Using conn As New SqlConnection("server=WIN10;database=pc_parts;user=admin;password=12345;")
Using cmd As New SqlCommand
With cmd
.Connection = conn
.CommandType = CommandType.Text
.CommandText = search
.Parameters.AddWithValue("@build", ebuildnumber.Text)
End With
Try
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader
If reader.HasRows Then
With reader
reader.Read()
ebrand.Text = .GetValue(1)
epart.Text = .GetValue(2)
equantity.Text = .GetValue(3)
edate.Text = .GetValue(4)
reader.Close()
End With
Else
MsgBox("Build Number Not Found")
End If
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Using
End Using
End Sub