How to retrieve data from database and put it into text box...

Apr 19 2004 7:56 AM
Actually, I am doing about a search function. Users enter customer ID (which is auto number in Access file) and then find the customers, then show the details in the text box. However, I cannot do that because some reasons like references problem ...etc. ---Here is the code-- Public Class Customer Inherits System.Windows.Forms.Form Private connection As OleDbConnection Private command As OleDbCommand Private adapter As OleDbDataAdapter Private Sub btnM_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnM_Search.Click connection.Open() Dim dt As New DataTable adapter = New OleDbDataAdapter(GetAll, connection) command.Connection = connection command.CommandText = "SELECT * FROM tblCustomer WHERE customer_ID = _ @customer_id " command.Parameters.Add("@customer_id", txtM_Item.Text) adapter.Fill(dt) txtM_CustomerID.DataBindings.Clear() txtM_CustomerName.DataBindings.Clear() txtM_phone.DataBindings.Clear() txtM_CustomerID.DataBindings.Add("Text", dt, "customer_ID") txtM_CustomerName.DataBindings.Add("Text", dt, "customer_name") txtM_phone.DataBindings.Add("Text", dt, "phone") connection.Close() End Sub --- end of code --- Thank you very much

Answers (1)