Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a query on Oracle that returns a value:

XML
SELECT a.ship_date ,a.judge_flag from ship_pallet_info  a inner join ship_request_info
b on a.ship_request_no = b.ship_request_no
where a.ship_date between :date1 and :date2 and a.judge_flag= :judgement;



and same query in ASP.NET like this but does not return any value:

<pre lang="vb">code.OCon.Close()
          code.OCon.Open()
          Dim cmd As New OracleCommand(&quot;SELECT * from ship_pallet_info  a inner join ship_request_info  b on a.ship_request_no = b.ship_request_no where a.ship_date between :date1 and :date2 and a.judge_flag = :judge&quot;, code.OCon)
          cmd.Parameters.Add(New OracleParameter(&quot;date1&quot;, txtPeriod_1.Text))
          cmd.Parameters.Add(New OracleParameter(&quot;date2&quot;, txtPeriod_1.Text))
          cmd.Parameters.Add(New OracleParameter(&quot;judge&quot;, txtPeriod_1.Text))
          Dim dt As New DataTable
          Dim da As New OracleDataAdapter(cmd)
          da.Fill(dt)
          gvShippingStatus.DataSource = dt
          gvShippingStatus.DataBind()</pre>



What's wrong with my code? Any help? Thanks!
Posted
Comments
Sascha Lefèvre 27-Apr-15 21:23pm    
Is ship_pallet_info.ship_date really a text-column?
NekoNao 27-Apr-15 21:40pm    
yes its varchar2.. the problem when i add ship_pallet_info.judge_flag there is no result returning.

1 solution

You're using txtPeriod_1.Text as the value for all three parameters. While it may be intended (but probably not) for date1 and date2, for judge it's certainly by mistake.

Possibly not related to the problem here, but storing dates as text is a really bad idea.

I also would suggest you to use more expressive names for your controls. You might have spotted this yourself if your textbox-variables had names like "FromDateInput", "UntilDateInput" and "JudgeFlagInput" ;)
 
Share this answer
 
v2
Comments
NekoNao 27-Apr-15 22:48pm    
I have changed the textbox Still dont have result
Sascha Lefèvre 27-Apr-15 22:57pm    
Please run your app in the debugger and copy the actual values of your textboxes to Notepad or something. Then insert the copied values into the query in Sql-Developer and see if you still get a result there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900