Hi all,
I'm no DB expert and this is my first time working with Oracle so bear with me. I have two DateTimePickers (sellOffStart and sellOffEnd) which I use their values when querying the database. So, I'm doing this:
vb.net Code:
  1. Dim sql As String = _
  2.     "select  " & _
  3.         "cus.FIELD_VALUE as ""Sell Off Date"", " & _
  4.         "ag.AGREEMENTS_ABBR as ""Licensor Number"", " & _
  5.         "ag.AGREEMENTS_NAME as ""Project"" " & _
  6.     "from V_REPCUSTOMFIELDDATA cus " & _
  7.         "right join V_AGREEMENT ag " & _
  8.             "on cus.ASSOCIATED_WITH_INTERNAL_KEY = ag.CONTRACT_CODE " & _
  9.     "where " & _
  10.         "cus.INTERNAL_DESCRIPTIONS_CODE = 35 " & _
  11.         "and ag.AGREEMENTS_ABBR LIKE :licensorNum " & _
  12.         "and cus.FIELD_VALUE between " & _
  13.             "to_date(:sellOffStart, 'MM/DD/YY HH12:MI:SS AM') and to_date(:sellOffEnd, 'MM/DD/YY HH12:MI:SS AM') " & _
  14.     "order by " & _
  15.         """Sell Off Date"", " & _
  16.         """Licensor Number"""
  17.  
  18. Dim cmd As New OracleCommand(sql, conn)
  19. cmd.Parameters.AddWithValue("licensorNum", "%" & Me.sellOffLicensorNum.Text & "%")
  20. cmd.Parameters.AddWithValue("sellOffStart", Me.sellOffStart.Value.ToString())
  21. cmd.Parameters.AddWithValue("sellOffEnd", Me.sellOffEnd.Value.ToString())

Am I supposed to ToString() the DateTimePicker.value and then use Oracle's TO_DATE() to turn that string right back into Oracle's DATE? Is this how I am supposed to do this?

It works, but I'm just curious if this is the "correct" way.

Thanks for helping this DB rookie.