4 Replies - 652 Views - Last Post: 08 July 2011 - 08:29 PM Rate Topic: -----

#1 naveed_786  Icon User is offline

  • D.I.C Regular

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

Data grid Searching Problem in VB.NET

Posted 07 July 2011 - 07:01 AM

Dear All,

I have a problem while searching in VB.NET using data grid

I am using this peace of code to search record here my function,nothing happens when i enter search field in text box and click on search button

Private Sub GetData() 
Try 

myDA =New OleDbDataAdapter("SELECT * FROM EQUIPMENT_INV ORDER BY ITEM_ID WHERE LOWER(ITEM_TYPE) LIKE '%" & txtcriteria.Text.ToLower() & "%'", ConnectionString) 
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA) 
mydataset =New DataSet() 
myDA.Fill(mydataset,"EQUIPMENT_INV") 
bindingsource1.DataSource = mydataset.Tables("EQUIPMENT_INV") 
Catch ex As Exception 
bindingsource1.DataSource = Nothing  
End Try  
End Sub 


and on btnsearch


GetData()
DataGridView1.DataSource = bindingsource1


what is the probelm in this peace of code.

Is This A Good Question/Topic? 0
  • +

Replies To: Data grid Searching Problem in VB.NET

#2 billyboy630  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 94
  • Joined: 09-October 09

Re: Data grid Searching Problem in VB.NET

Posted 07 July 2011 - 01:41 PM

Its hard to say not seeing all the code for your connectionstring
what type of datafile you are searching etc...

Go step by step and see if you even connecting to your datafile

Why dont you put a messagebox to show what exception message you are getting. I would guess your not getting a DataTable at all

Catch ex As Exception
MsgBox(ex.Message)

Let me know what you get

This post has been edited by billyboy630: 07 July 2011 - 01:42 PM

Was This Post Helpful? 0
  • +
  • -

#3 naveed_786  Icon User is offline

  • D.I.C Regular

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

Re: Data grid Searching Problem in VB.NET

Posted 08 July 2011 - 12:32 AM

I am receiving the following error please view the image for error detail i am using oracle db.

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#4 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: Data grid Searching Problem in VB.NET

Posted 08 July 2011 - 05:34 AM

Try this way
move ORDER BY at the end of string
and use LCASE instead of LOWER function
you might be want to use string.Format to
build query as well, just a hint
Perhaps it will helps:
       Dim criteria As String = txtcriteria.Text.ToLower
        Dim OleDbSb As New OleDbConnectionStringBuilder()
        OleDbSb.Provider = "Microsoft.ACE.OLEDB.12.0"
        OleDbSb.DataSource = "C:\Users\Test\Desktop\data.mdb"
        OleDbSb.PersistSecurityInfo = True
        myConn = New OleDbConnection(OleDbSb.ConnectionString)
        myConn.Open()
        Dim strSQL As String = "SELECT * FROM EQUIPMENT_INV WHERE LCASE(ITEM_TYPE) LIKE '%" & criteria & "%'  ORDER BY ITEM_ID"
        myDA = New OleDbDataAdapter(strSQL, myConn)
        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
        myDA.SelectCommand = New OleDbCommand(strSQL, myConn)
        myDT = New DataTable()
        myDA.Fill(myDT)
        Me.bindingSource1.DataSource = myDT
        Me.DataGridView1.DataSource = Me.bindingSource1
        myConn.Close()


~'J'~
Was This Post Helpful? 0
  • +
  • -

#5 naveed_786  Icon User is offline

  • D.I.C Regular

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

Re: Data grid Searching Problem in VB.NET

Posted 08 July 2011 - 08:29 PM

Thanks for your reply Fixo i have resolved the problem.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1