5 Replies - 589 Views - Last Post: 12 July 2011 - 12:36 AM Rate Topic: -----

#1 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Query Problem in VB.NET

Posted 10 July 2011 - 10:34 AM

I am using VB.NET as front end and oracle 9i as db my problem is this i am writing this query to fetch records between two dates from Key_rec table but the problem is this when i enter the report using dtpicker1 and dtpicker2 these two values goes in txtfrom and txtto then i press view report button but it shows blank report but when i enter the date manually from key board it works fine its mean nothing is wrong with the query there is some problem with the dtpicker1 and dtpicker2 here is the query on btnrep

myDA = New OleDbDataAdapter("SELECT * FROM KEY_MAKING_REC WHERE DT BETWEEN TO_DATE('" & txtfrom.Text & "','mm/dd/yyyy ') AND TO_DATE('" & txtto.Text & "','mm/dd/yyyy')", ConnectionString)


and here is the code for dtpicker1 & 2

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
        txtfrom.Text = DateTimePicker2.Value.ToShortDateString()
    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        txtto.Text = DateTimePicker1.Value.ToShortDateString()
    End Sub


Please view this code and tell me what could be the possible issue.

Is This A Good Question/Topic? 0
  • +

Replies To: Query Problem in VB.NET

#2 kingsonprisonic  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 74
  • Joined: 09-July 09

Re: Query Problem in VB.NET

Posted 10 July 2011 - 11:09 AM

I think your DateTimePicker Control use its default format. If yes.
Then
Change it to custom format. And in the ustom format put MM/dd/yyyy

View this Image

If i am wrong let me know.
Was This Post Helpful? 1
  • +
  • -

#3 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Re: Query Problem in VB.NET

Posted 10 July 2011 - 11:50 AM

Yes you are right i am trying but when i select the date from dtpicker1 it assigns the date value to txtto in this format 07/11/11 but i need in this format "07/11/2011" how to achieve this???
Was This Post Helpful? 0
  • +
  • -

#4 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Query Problem in VB.NET

Posted 10 July 2011 - 10:07 PM

Or try it through code:
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy";

Was This Post Helpful? 1
  • +
  • -

#5 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Re: Query Problem in VB.NET

Posted 11 July 2011 - 10:03 PM

NO it is not resolving my problem same result. it is giving same result
Was This Post Helpful? 0
  • +
  • -

#6 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Re: Query Problem in VB.NET

Posted 12 July 2011 - 12:36 AM

I have resolved the issue by changing this line of code

txtfrom.Text = DateTimePicker1.Value.ToString("MM/dd/yyyy")


Thanks for help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1