4 Replies - 3495 Views - Last Post: 29 April 2010 - 03:21 AM Rate Topic: -----

#1 Needanswer  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 61
  • Joined: 27-January 10

vb.net with access - search records from the textbox

Posted 28 April 2010 - 09:03 PM

I want to get an input from the textbox, and display the records into the datagridview, BUT IS POSSIBLE IF NO RECORDS, THE DATAGRIDVIEW SHOWS ONLY EMPTY CELLS??

this is the code to display records.
        con1.Open()
        sqlsearch = "SELECT * FROM setting WHERE mname LIKE'%" &  
        TextBox1.Text & "%'"

        Dim adapter As New OleDbDataAdapter(sqlsearch, con1)
        Dim dt As New DataTable("setting")
        adapter.Fill(dt)
        Form2.DataGridView1.DataSource = dt

        con1.Close()

        RefreshDGV()


This post has been edited by Needanswer: 28 April 2010 - 09:04 PM


Is This A Good Question/Topic? 0
  • +

Replies To: vb.net with access - search records from the textbox

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: vb.net with access - search records from the textbox

Posted 28 April 2010 - 09:05 PM

Well if there are no matching records how do you expect anything to be displayed?
Was This Post Helpful? 0
  • +
  • -

#3 Needanswer  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 61
  • Joined: 27-January 10

Re: vb.net with access - search records from the textbox

Posted 28 April 2010 - 09:17 PM

View PostPsychoCoder, on 28 April 2010 - 08:05 PM, said:

Well if there are no matching records how do you expect anything to be displayed?


Actually, on the beginning, the datagridview will bind the database, can I do a empty datagridview to start a search?
Was This Post Helpful? 0
  • +
  • -

#4 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: vb.net with access - search records from the textbox

Posted 28 April 2010 - 10:46 PM

If your asking if you can clear the contents of the datagrid at the start - the answer is yes you can.
Was This Post Helpful? 1
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: vb.net with access - search records from the textbox

Posted 29 April 2010 - 03:21 AM

Are you needing the ability to edit any records (when you have results) in the datagridview or is this just for display?

If you don't need to edit the records you could use a listview instead this would give you the same basic layout as a populated datagridview.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1