Get table data for updating

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
6
Indexable
Never
private async void GetStudentDetails()
        {
            await Conopen();
            Strsql = "Select * from V_Students where lrn = '" + SelectedStudentId + "'";
            Sqlcmd.CommandText = Strsql;
            Sqlcmd.Connection = Cnn;
            Sqladapter.SelectCommand = Sqlcmd;
            Sqlreader = Sqlcmd.ExecuteReader();
            //metroComboBox1.Items.Clear();
            if (Sqlreader.Read())
            {
                txtLrn.Text = Sqlreader["LRN"].ToString();
                txtfname.Text = Sqlreader["F_name"].ToString();
                txtlname.Text = Sqlreader["L_name"].ToString();
                pickerbdate.Text = Sqlreader["B_Date"].ToString();
                txtaddress.Text = Sqlreader["Address"].ToString();
                txtstudentmobile.Text = Sqlreader["S_mobile_number"].ToString();
                cbogender.Text = Sqlreader["gender"].ToString();
                guardianId = Sqlreader["guardian_id"].ToString();
                studentimg.Source =
                    new BitmapImage(new Uri(
                        $"file:///{currentAssemblyParentPath}/net6.0-windows/StudentImages/{Sqlreader["img"]}"));
                txtguardianname.Text = Sqlreader["guardian_name"].ToString();
                txtrelationship.Text = Sqlreader["guardian_relationship"].ToString();
                txtguardianaddress.Text = Sqlreader["guardian_address"].ToString();
                txtguardianmobile.Text = Sqlreader["guardian_mobile"].ToString();
            }
            Sqlcmd.Dispose();
            Sqlreader.Close();
            Cnn.Close();
            Strsql = "";
        }