| | |
[Databinding]
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 28
Reputation:
Solved Threads: 0
Hi,
I need help with importing database into form. The problem that I am having is, when a user inputs their firstname into textbox1, it should search for their name in the database (MS Access) , if found, it should populate the information into each textbox such as lastname, address and etc.., I know that you have to use datareader to do that and databinding to add the information to the textboxes, but how do I do the search and then populate the information. I am using access database. Can you please help me on this?
Thanks in advance!
I need help with importing database into form. The problem that I am having is, when a user inputs their firstname into textbox1, it should search for their name in the database (MS Access) , if found, it should populate the information into each textbox such as lastname, address and etc.., I know that you have to use datareader to do that and databinding to add the information to the textboxes, but how do I do the search and then populate the information. I am using access database. Can you please help me on this?
Thanks in advance!
you can do generally searching??
if u can, its a same technique.
put you search procedure in text change event. so when user input data on textbox it will searching others data.
but why u using first name as searching key??
how about if you have 2 same frist name in your database??why you didn't used their id?
if u can, its a same technique.
put you search procedure in text change event. so when user input data on textbox it will searching others data.
but why u using first name as searching key??
how about if you have 2 same frist name in your database??why you didn't used their id?
Last edited by Jx_Man; Apr 5th, 2008 at 1:51 am.
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 *
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Solved Threads: 1
I the dataset designer create a TableAdapter with the following DML:
SELECT * FROM Table WHERE Name LIKE '%?%'
Add the DataSet and the TableAdapter to the form and bind the controls (I recomend a DataGrid to see all the records that math the query).
In the TextBox1 open the Text Change Event and write the following code:
TABLEADAPTER_NAME.FILL(DataSet.TableName, TextBox1.Text.Trimm)
Sorry for my bad english.
SELECT * FROM Table WHERE Name LIKE '%?%'
Add the DataSet and the TableAdapter to the form and bind the controls (I recomend a DataGrid to see all the records that math the query).
In the TextBox1 open the Text Change Event and write the following code:
TABLEADAPTER_NAME.FILL(DataSet.TableName, TextBox1.Text.Trimm)
Sorry for my bad english.
•
•
Join Date: Jan 2008
Posts: 28
Reputation:
Solved Threads: 0
Hi,
Here is my code to do a Select function. However, how do I modify this code to do a search function. In other words, the user has to input the customerID onto a textbox 1, which then searches for the information in the database and populate it to all other textboxes. Right now, my code has data populated into a datagrid. Can anyone help? Thanks in advance!
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\testing\nwind.mdb;")
Dim myComamand As New OleDbCommand
Dim myDataReader As OleDbDataReader
Dim myDataTable As New DataTable
Try
myConnection.Open()
myComamand.CommandType = CommandType.Text
myComamand.Connection = myConnection
myComamand.CommandText = "Select CustomerID From Customers"
myDataReader = myComamand.ExecuteReader()
myDataTable.Load(myDataReader)
DataGridView1.DataSource = myDataTable
Catch ex As Exception
MsgBox(ex.Message)
Finally
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If
End Try
Here is my code to do a Select function. However, how do I modify this code to do a search function. In other words, the user has to input the customerID onto a textbox 1, which then searches for the information in the database and populate it to all other textboxes. Right now, my code has data populated into a datagrid. Can anyone help? Thanks in advance!
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\testing\nwind.mdb;")
Dim myComamand As New OleDbCommand
Dim myDataReader As OleDbDataReader
Dim myDataTable As New DataTable
Try
myConnection.Open()
myComamand.CommandType = CommandType.Text
myComamand.Connection = myConnection
myComamand.CommandText = "Select CustomerID From Customers"
myDataReader = myComamand.ExecuteReader()
myDataTable.Load(myDataReader)
DataGridView1.DataSource = myDataTable
Catch ex As Exception
MsgBox(ex.Message)
Finally
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If
End Try
do you want to populate data in datagrid or other control (label or textbox).
i looks in your code you able to populate in datagrid. so try this to populate in textbox or label.
add this code on your code :
i looks in your code you able to populate in datagrid. so try this to populate in textbox or label.
add this code on your code :
VB.NET Syntax (Toggle Plain Text)
If myReader.HasRows Then While myReader.Read() txtFirstName.text= myReader.Item("FirstName") End While End If myReader.Close()
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
- DataBinding (C#)
- Help with Databinding (ASP.NET)
- Working with SQL's Text data type (ASP.NET)
- Adding a checkbox column dynamically (C#)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: .Net Battler Needing help Desperately lol!
- Next Thread: Visual Basic.net Database application
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account advanced application array basic beginner browser button buttons center click code combo cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel exists fade filter forms ftp generatetags html images input insert intel internet listview mobile module monitor net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown soap socket sqldatbase sqlserver survey temperature textbox timer timespan transparency trim txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year






