Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void AcNotextBox_TextChanged(object sender, EventArgs e)
        {
            int id;
            if (!int.TryParse(AcNotextBox.Text, out id))
            {
                return;
            }
            string connString = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;

            string cmdString = "SELECT * FROM tblBasicInfo WHERE ID =" +Convert.ToString(AcNotextBox.Text);

            string cmdStringg = "SELECT * FROM tblAccData WHERE ID =" + Convert.ToString(AcNotextBox.Text);

            using (OleDbConnection conn = new OleDbConnection(connString))
            {
                using (OleDbCommand cmd = new OleDbCommand(cmdString, conn))
                {
                    cmd.Parameters.AddWithValue("ID", id);
                    conn.Open();

                    OleDbDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        NametextBox.Text = (reader["SName"].ToString());
                        FNametextBox.Text = (reader["FName"].ToString());
                        AddresstextBox.Text = (reader["Address"].ToString());
                        CelltextBox.Text = (reader["Cell"].ToString());
                        NationalitytextBox.Text = (reader["Nationality"].ToString());
                        ReligiontextBox.Text = (reader["Religion"].ToString());
                        FCNICNotextBox.Text = (reader["FCNICNo"].ToString());
                        FatherOccuptextBox.Text = (reader["FOccup"].ToString());
                        TransportFacilitytextBox.Text = (reader["TranFacility"].ToString());
                        InFiguredateTimePicker.Text = (reader["DOB"].ToString());
                        DateofAdmdateTimePicker.Text = (reader["DateofAdm"].ToString());
                        RegistrationNotextBox.Text = (reader["RegNo"].ToString());
                        TranFeetextBox.Text = (reader["TransportChr"].ToString());
                        SRemarkstextBox.Text = (reader["SpecialRemarks"].ToString());
                        ClassofcomboBox.Text = (reader["ClassofAdm"].ToString());
                        ClassOfReadcomboBox.Text = (reader["ClassofReading"].ToString());
                    }
                }


What I have tried:

how to add multi table data ne window fox 9 text box i want to set or fill, dispaly data in c# Please Help me
Posted
Updated 17-Feb-18 2:04am
v3

1 solution

See answers here: c# - Loading DataTable with multiple tables select query - Stack Overflow[^]

You can use INNER JOIN in Access as follows, see INNER JOIN Operation (Microsoft Access SQL)[^]
SELECT CategoryName, ProductName 
FROM Categories INNER JOIN Products 
ON Categories.CategoryID = Products.CategoryID;
Here is an example how to load a DataTable from Access, copied from Using Microsoft Access Database In C# . . . ADO.NET In Winforms/WPF For Beginners[^]
var conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=Store.mdb;");
conn.Open();
var dtCustomers = new DataTable();

var adapter = new OleDbDataAdapter("SELECT * FROM Customers;",
    conn);
adapter.Fill(dtCustomers);

dataGridView1.DataSource = dtCustomers;
 
Share this answer
 
v3
Comments
NOOR ULLAH JAN 17-Feb-18 7:28am    
this is not working for me i have use Access Data base your code is SQL
please read my code and solut my problem
RickZeeland 17-Feb-18 8:34am    
Access uses SQL, see the updated answer !
NOOR ULLAH JAN 18-Feb-18 8:18am    
not working plzzz
string cmdString = "SELECT * FROM tblBasicInfo WHERE ID =" +Convert.ToString(AcNotextBox.Text);

string cmdStringg = "SELECT * FROM tblAccData WHERE ID =" + Convert.ToString(AcNotextBox.Text);

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