Search value by textbox from .mdb file

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2007
Posts: 78
Reputation: kerek2 is an unknown quantity at this point 
Solved Threads: 0
kerek2 kerek2 is offline Offline
Junior Poster in Training

Search value by textbox from .mdb file

 
0
  #1
Feb 3rd, 2009
Hi Guys,

I'm really need help for this item, the situation is i got textbox1 as a input , button1 as searchbutton abd textbox2 to display the item that been enter in textbox1. All the table from .mdb

Can guide me plz
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #2
Feb 3rd, 2009
I really don't understand a thing about your question!

If you are asking for some help you really need to explain everything into details. We can't guess about what your goals are.....
Last edited by 4advanced; Feb 3rd, 2009 at 5:59 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 78
Reputation: kerek2 is an unknown quantity at this point 
Solved Threads: 0
kerek2 kerek2 is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #3
Feb 3rd, 2009
Thank you for reply,

Actually i need do make one searchbox to search a data. It's make one textbox as inputbox, when click the button, it will refer to .mdb database table. and the result will display in another textbox. For inputbox just accept 10 character and the display will be name of person..can u guide me?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Search value by textbox from .mdb file

 
0
  #4
Feb 4th, 2009
Do you already have your connection strings setup for the mdb? I will go with yes
are you sure that the search will only return one entry in the db? i would probably go with either a listbox or datagrid to display the returns.
this is a nice little tutorial for displaying data in a datagrid. http://www.vbdotnetheaven.com/Upload...aGridSamp.aspx all you will need to do is change the query.
  1. Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers", myConnection)
  2. 'to this
  3. Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers Where FirstName like " & me.txtsearch.text & "%", myConnection)
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 78
Reputation: kerek2 is an unknown quantity at this point 
Solved Threads: 0
kerek2 kerek2 is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #5
Feb 4th, 2009
the connection string to mdb still stuck...i'm confuse where to start the coding...below button click or textbox?....plz help me
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Search value by textbox from .mdb file

 
0
  #6
Feb 4th, 2009
button click
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 78
Reputation: kerek2 is an unknown quantity at this point 
Solved Threads: 0
kerek2 kerek2 is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #7
Feb 4th, 2009
Then how to link from textbox to database.mdb?...plz can give me a sample for connection and search method?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #8
Feb 4th, 2009
At least you are pointing to the right directions at this moment. The questions you ask seem to me you are now in the right 'developer-mode' :=)

Professor can be right but it's up to you where to open the connection. In most cases, and esspecially for .Net, the connections are made when you want to query, update, insert or delete something from the database and close it when ready. Anyways, you still can open the connection whenever you want & close it whenever you want.

In the case of using Access as a backend database, you're out of many options. You got to remember that Access is a file-based database which means that if you query some tables, all the tables in the query are pulled over to the client and after that they are being queried (client side). With a lot of data, you can experience a lot of performance problems.

Pointing to your question: leave all database actions within the button_click, as ProfessorPC suggested. Take a look at this post http://www.daniweb.com/forums/thread172996.html and look for rapture's code examples on oledb connections etc....
Also ProfessorPC's example is a nice solution

Regards,
Richard
The Netherlands
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 78
Reputation: kerek2 is an unknown quantity at this point 
Solved Threads: 0
kerek2 kerek2 is offline Offline
Junior Poster in Training

Re: Search value by textbox from .mdb file

 
0
  #9
Feb 4th, 2009
I'm already thry this code,but the result appear all the name,it not searching by id.....how to do that bro?....pls...



"Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  1. 'Create a connection to the database
  2. Dim cn As OleDbConnection
  3. Dim cmd As OleDbCommand
  4. Dim dr As OleDbDataReader
  5. Dim Sql As String
  6.  
  7. Try
  8. cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Database1.mdb;")
  9. 'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; _Data Source=D:\Database1.mdb;")
  10. 'provider to be used when working with access database
  11. 'cn.Open()
  12. cmd = New OleDbCommand("SELECT * from UMP WHERE ", cn)
  13.  
  14.  
  15. cn.Open()
  16.  
  17.  
  18.  
  19.  
  20. dr = cmd.ExecuteReader
  21. While dr.Read()
  22.  
  23.  
  24. ListBox1.Items.Add(dr(2))
  25. 'TextBox1.Text = dr(2)
  26. 'TextBox2.Text = dr(1)
  27. 'TextBox3.Text = dr(2)
  28. ' loading data into TextBoxes by column index
  29. End While
  30.  
  31. Catch ex As Exception
  32.  
  33. End Try
  34.  
  35. 'dr.Close()
  36. cn.Close()
  37.  
  38. End Sub
Last edited by Ancient Dragon; Feb 5th, 2009 at 7:24 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Search value by textbox from .mdb file

 
1
  #10
Feb 4th, 2009
use condition on your select statment.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC