3 Replies - 3008 Views - Last Post: 30 October 2011 - 09:22 PM Rate Topic: -----

#1 caello  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-September 11

how to search data by textbox and date in VB.net

Posted 29 October 2011 - 11:12 AM

Hi..all
I'm newbie in VB.net
Please Help me..
How to search data by textbox and datetimepicker access 2003 database in VB.net

Exp : I want to search for data based on the Part name and two datetimepicker

I try with code like this but the results are not in line with expectations

Private Sub SearchData()
con.Open()
        Dim dt As New DataTable
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        Dim da As New OleDbDataAdapter
        'da = New OleDbDataAdapter(com)
        If cbaktif.Checked = True Then
            da = New OleDbDataAdapter("Select * from AFINITY where Description = '" & TextBox1.Text & "' and " & " Datetgl between #" & DateTimePicker1.Text & "# and #" & DateTimePicker2.Text & "# ", con)
        Else
            da = New OleDbDataAdapter("Select * from AFINITY where Description like '%" & TextBox1.Text & "%'", con)
        End If
        da.Fill(dt)
        DatagridView1.DataSource = dt.DefaultView
        con.Close()
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: how to search data by textbox and date in VB.net

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9069
  • View blog
  • Posts: 34,083
  • Joined: 12-June 08

Re: how to search data by textbox and date in VB.net

Posted 30 October 2011 - 11:43 AM

What sql query are you looking to write? *How* is it not in align with what you are looking for?
Was This Post Helpful? 0
  • +
  • -

#3 caello  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-September 11

Re: how to search data by textbox and date in VB.net

Posted 30 October 2011 - 05:35 PM

I don't know?..
Because i'm very newbie, if my code is correct or not, because I learn a new one this month,
can you give examples of how the code is correct as my case? .
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9069
  • View blog
  • Posts: 34,083
  • Joined: 12-June 08

Re: how to search data by textbox and date in VB.net

Posted 30 October 2011 - 09:22 PM

If I knew what data you were trying to get and why you think it's not the data you want I would be of much greater help...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1