Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing parameters for date in Oracle query
    primarykey
    data
    text
    <p>I have a set of queries I am running out of VB.NET codebehind on a web page that read a user's input for start and end dates. Here is the code/query:</p> <pre><code>strOraQuery = "SELECT a.col1, a.col2, a.col3 " &amp; _ "FROM a_table a LEFT JOIN b_table b ON (a.col1=b.col1) " &amp; _ "WHERE a.datecol BETWEEN :startdate AND :enddate" oracmd = New OracleCommand(strOraQuery, oracn) oracmd.Parameters.Add(New OracleParameter(":enddate", strEndDate)) oracmd.Parameters.Add(New OracleParameter(":startdate", strStartDate)) </code></pre> <p>EDIT #2: These parameters are actually out of order in my code, so I flipped them to show the issue that I was actually having. Refer to answers/comments below.</p> <p>strStartDate and strEndDate are both in mm/dd/yyyy format.</p> <p>This bit of code runs the query through a DataReader and into a DataTable. The error I am receiving from running the query is </p> <blockquote> <p>ORA-01858: a non-numeric character was found where a numeric was expected</p> </blockquote> <p>I have tried to change the query and the Parameters.Add() statement around in at least a dozen different ways and nothing has worked yet. What am I doing wrong?</p> <p>Thank you.</p> <p>EDIT:</p> <p>The start and end dates are global variables declared and set like so:</p> <pre><code>Dim strStartDate As String Dim strEndDate As String Protected Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click strStartDate = txtStartDate.Text strEndDate = txtEndDate.Text ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload