| | |
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:
Solved Threads: 0
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?
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?
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
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.

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)
Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers", myConnection) 'to this Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers Where FirstName like " & me.txtsearch.text & "%", myConnection)
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
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
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
•
•
Join Date: Sep 2007
Posts: 78
Reputation:
Solved Threads: 0
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
"Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
VB.NET Syntax (Toggle Plain Text)
'Create a connection to the database Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Dim Sql As String Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Database1.mdb;") 'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; _Data Source=D:\Database1.mdb;") 'provider to be used when working with access database 'cn.Open() cmd = New OleDbCommand("SELECT * from UMP WHERE ", cn) cn.Open() dr = cmd.ExecuteReader While dr.Read() ListBox1.Items.Add(dr(2)) 'TextBox1.Text = dr(2) 'TextBox2.Text = dr(1) 'TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch ex As Exception End Try 'dr.Close() cn.Close() End Sub
Last edited by Ancient Dragon; Feb 5th, 2009 at 7:24 am. Reason: add code tags
use condition on your select statment.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- Previous Thread: Datagrid MS Access and VB.Net
- Next Thread: DateTime field - How do I assign a time other than current?
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access add arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net employees excel file-dialog firewall folder ftp hardcopy image images isnumericfuntioncall login math memory mobile module ms mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port printpreview problemwithinstallation project record reports" reuse save savedialog serial soap storedprocedure string tcp temp text textbox timer toolbox trim updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf






