943,660 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3609
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 3rd, 2009
0

Search value by textbox from .mdb file

Expand Post »
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
Similar Threads
Reputation Points: 20
Solved Threads: 0
Junior Poster
kerek2 is offline Offline
113 posts
since Sep 2007
Feb 3rd, 2009
0

Re: Search value by textbox from .mdb file

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.
Reputation Points: 33
Solved Threads: 10
Junior Poster in Training
4advanced is offline Offline
67 posts
since Nov 2008
Feb 3rd, 2009
0

Re: Search value by textbox from .mdb file

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?
Reputation Points: 20
Solved Threads: 0
Junior Poster
kerek2 is offline Offline
113 posts
since Sep 2007
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

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.
vb.net Syntax (Toggle Plain Text)
  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)
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

the connection string to mdb still stuck...i'm confuse where to start the coding...below button click or textbox?....plz help me
Reputation Points: 20
Solved Threads: 0
Junior Poster
kerek2 is offline Offline
113 posts
since Sep 2007
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

button click
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

Then how to link from textbox to database.mdb?...plz can give me a sample for connection and search method?
Reputation Points: 20
Solved Threads: 0
Junior Poster
kerek2 is offline Offline
113 posts
since Sep 2007
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

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
Reputation Points: 33
Solved Threads: 10
Junior Poster in Training
4advanced is offline Offline
67 posts
since Nov 2008
Feb 4th, 2009
0

Re: Search value by textbox from .mdb file

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

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 20
Solved Threads: 0
Junior Poster
kerek2 is offline Offline
113 posts
since Sep 2007
Feb 4th, 2009
2

Re: Search value by textbox from .mdb file

use condition on your select statment.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Datagrid MS Access and VB.Net
Next Thread in VB.NET Forum Timeline: DateTime field - How do I assign a time other than current?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC