title: Conversion failed when converting datetime from character string
body: <p>The string passed to my custom function is the following:</p>
  
  <pre><code>SELECT key FROM ubis WHERE MemberID = '144'
  AND To &gt;='11/7/2009 9:11:23 pm'
  AND From &lt;= '11/7/2009 9:11:23 pm'
  
      Public Shared Function GetDataTable(ByVal CmdText As String) As DataTable
          Dim myConn As New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").ConnectionString)
          Dim myCmd As New SqlCommand(CmdText, myConn)
          myConn.Open()
          Dim myReader As SqlDataReader = myCmd.ExecuteReader()
          Dim myTable As New DataTable()
          myTable.Load(myReader)
          myConn.Close()
          Return (myTable)
      End Function
  </code></pre>
  
  <p>and here is the error i get,
  Conversion failed when converting datetime from character string</p>
  
  <p>I understand that the the datetime fields are passed as string into the function, but what options do i have?</p>