0

I am trying to pass a variable to a sql script and run in using c#.

I get an error saying

"missing expression".

fromDate and toDate are passed as 'dd//mm//yy format. Am i not passing the parametres coorectly using OracleCommand ?

public void TransactionReport(string fromDate, string toDate)
        {
            string query = "select s.store_code,count(i.invc_sid) as count from invoice_v i Left join store_v s ON i.sbs_no = s.sbs_no and i.store_no = s.store_no Where(i.created_date between to_date(@fromDate,'MM//DD//YY') and to_date(@toDate,'MM//DD//YY'))  and i.proc_status not in ('131072','65536','147456', '81920') and i.invc_type = 0 AND i.sbs_no = 6  GROUP BY  s.store_code";
            conn.Open();
            using (OracleCommand cmd = new OracleCommand(query, conn))
            {
                cmd.Parameters.Add(new OracleParameter("fromDate", fromDate));
                cmd.Parameters.Add(new OracleParameter("toDate", toDate));
                OracleDataReader dr = cmd.ExecuteReader();
Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
user2539119
  • 29
  • 1
  • 4

2 Answers2

0

Try : instead of @

string query = "select s.store_code,count(i.invc_sid) as count from invoice_v i Left join store_v s ON i.sbs_no = s.sbs_no and i.store_no = s.store_no Where(i.created_date between to_date(:fromDate,'MM//DD//YY') and to_date(:toDate,'MM//DD//YY'))  and i.proc_status not in ('131072','65536','147456', '81920') and i.invc_type = 0 AND i.sbs_no = 6  GROUP BY  s.store_code";
Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
0

In the Oracel you should not use the sign @, this is only in SQL Server, remove the @ only and it will work...

Adel
  • 1,468
  • 15
  • 18