[Databinding]

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jan 2008
Posts: 28
Reputation: Time Indicator is an unknown quantity at this point 
Solved Threads: 0
Time Indicator Time Indicator is offline Offline
Light Poster

[Databinding]

 
0
  #1
Apr 4th, 2008
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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
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: [Databinding]

 
0
  #2
Apr 5th, 2008
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?
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 *
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 28
Reputation: Time Indicator is an unknown quantity at this point 
Solved Threads: 0
Time Indicator Time Indicator is offline Offline
Light Poster

Re: [Databinding]

 
0
  #3
Apr 7th, 2008
Hi,

Okay, If I were to search the ID, how do I go about that. Can you provide me a sample code? Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 2
Reputation: Mike Serrano is an unknown quantity at this point 
Solved Threads: 1
Mike Serrano Mike Serrano is offline Offline
Newbie Poster

Re: [Databinding]

 
0
  #4
Apr 7th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 28
Reputation: Time Indicator is an unknown quantity at this point 
Solved Threads: 0
Time Indicator Time Indicator is offline Offline
Light Poster

Re: [Databinding]

 
0
  #5
Apr 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
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: [Databinding]

 
3
  #6
Apr 8th, 2008
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 :
  1. If myReader.HasRows Then
  2. While myReader.Read()
  3. txtFirstName.text= myReader.Item("FirstName")
  4. End While
  5. End If
  6. myReader.Close()
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  
Join Date: Jan 2008
Posts: 28
Reputation: Time Indicator is an unknown quantity at this point 
Solved Threads: 0
Time Indicator Time Indicator is offline Offline
Light Poster

Re: [Databinding]

 
0
  #7
Apr 8th, 2008
Hi,

Thanks for all your help! It worked....
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