Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use Visual Studio 2010 with VB.Net and Microsoft Access Database.I have form Loan and form Equipment. In form Equipment i have item Equipment ID, Equipment Item,Model,Description,Quantity,Serial No and Status. In form Loan i have Equipment ID, Name,Staff ID,Telephone No,Department Equipment Item,Date Loan,Date Return and Period. When user key in Equipment ID in form Loan the Equipment Item will be set automatic after key in all detail in form Equipment. Tq for helping.
Posted
Updated 7-Apr-13 21:55pm
v2
Comments
Anurag Sinha V 8-Apr-13 3:48am    
What platform do you want to use?
via Backend? via Frontend?
Edit your question and please be more clear...Then people over here will be able to help you in the right direction..

-Anurag
tarhex 11-Apr-13 17:34pm    
You want equipment details based on the ID entered?
hanigbl 12-Apr-13 1:22am    
Yes. Can u help me? Tq
tarhex 12-Apr-13 8:15am    
I can help you but I need to know where you want the details to be displayed. Is it on Textboxes or DataGridView
hanigbl 15-Apr-13 21:30pm    
I want the details to be display on textboxes. Actually i use datagridview to display all item in form. Tq very much.

1 solution

Private Sub getDetails()



Dim ID As String = txtID.Text

Try


Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath & "\database\sample.accdb" + " ;Jet OLEDB:Database Password=sample;")


conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand("SELECT ID,amt,last_pay_date FROM details WHERE ID= " & ID & " ", conn)

Dim reader As OleDbDataReader = cmd.ExecuteReader
reader.Read()



'display amount details
txtAmount.Text = reader(1)

'close the connection
conn.Close()

End If


Catch ex As Exception

Dim mybox As New myMsgbox

With mybox
.txtError.Text = "An error has occured, cancel and try again!"
.ShowDialog()
End With

End Try

End Sub
 
Share this answer
 
Comments
hanigbl 16-Apr-13 23:26pm    
This code should place at my Equipment Item text box right? Sorry because im a new in this field. Tq.
hanigbl 17-Apr-13 1:46am    
Dim cmd As OleDbCommand = New OleDbCommand("SELECT ID,amt,last_pay_date FROM details WHERE ID= " & ID & " ", conn)= This SELECT ID i must get all detail from form Equipemtn right?
tarhex 18-Apr-13 14:41pm    
Dim cmd As OleDbCommand = New OleDbCommand("SELECT ID,amt,last_pay_date FROM details WHERE ID= " & ID & " ", conn)

In the code above, the "ID,amt,last_pay_date" are the columns (details) that can be displayed (in your case, equipment details). The "Details" is the name of the Table in the database.
hanigbl 21-Apr-13 21:23pm    
I only want the Equipment Item in form Equipment display in form Loan when i key in the Equipment ID. The code u give me i have put in form Loan under Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ? Tq for helping me.
tarhex 22-Apr-13 3:05am    
Are you adding data to database or retrieving from database?

The sample code I posted is to retrieve from database. post your code below let me see so that I can really help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900