private void EnterAcNotextBox_TextChanged(object sender, EventArgs e)
            int id;
            if (!int.TryParse(AcNotextBox.Text, out id))
            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))


                    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());


Recommended Answers

Is this a tutorial or was the question forgotten?
Read then update your discussion.

Jump to Post

All 2 Replies

From my opinion your problem should be in construction of sql statement i.e."SELECT '#' FROM tblBasicInfo, tblAccData WHERE ID =" + Convert.ToInt32(AcNotextBox.Text)

Use Inner join clause to join two tables.
You can try it

"SELECT A.ID,A.Name,.....,B.Pro FROM tblBasicInfo A Inner Join tblAccData B On B.ID=A.ID WHERE A.ID =" + Convert.ToInt32(AcNotextBox.Text)

***Use Parameterised queries to prevent sql injection to your database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.