Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
string connString = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;

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

            //string query = "SELECT * FROM tblAccData WHERE ID =" + Convert.ToInt32(AcNotextBox.Text);


            using (OleDbConnection conn = new OleDbConnection(connString))
            {
                using (OleDbCommand cmd = new OleDbCommand(cmdString, conn))


                {
                    conn.Open();

                    OleDbDataReader reader = cmd.ExecuteReader();
                    

                    if (reader.Read())
                    {
                        StudentNametextBox.Text = (reader["SName"].ToString());
                        FatherNametextBox.Text = (reader["FName"].ToString());
                        ClasscomboBox.Text = (reader["ClassofReading"].ToString());
                        TransportFatextBox.Text = (reader["TranFacility"].ToString());
                        RemarkstextBox.Text = (reader["Remarks"].ToString());
                        CelltextBox.Text = (reader["Cell"].ToString());
                        TrantextBox.Text = (reader["TransportChr"].ToString());
                        
                        DuestextBox.Text = (reader["Dues"].ToString());
                        AdmfeetextBox.Text = (reader["Adm"].ToString());
                        ProFeetextBox.Text = (reader["Pro"].ToString());


What I have tried:

MS Access how to fill dataset with multiple tables in c#


please help me ho set data from access multi table in textbox i have calling data for access from 1 form
Posted
Comments
RickZeeland 18-Feb-18 10:39am    
Please don't repost the same question and first try out the suggestions that you have been given !

1 solution

First of all, NEVER use concatenating string as a query. This exposes you on Sql Injection[^]. Rather than this, use parameterized queries[^].

A proper way to work with data is to create Data Access Layer[^] and Bussines Logic Layer[^].

Finally, i'd strongly recommend to read this: Writing a Portable Data Access Layer[^] and this: Simplified Database Access via ADO.NET Interfaces[^]
 
Share this answer
 

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