mardi 24 novembre 2015

Inventry Form Not Updating itself after Save data C# Winform

I want to include screen shots but stack overflow not letting me to do that.Hope I am clear to you in this way.In my application I want to autofill remaining text boxes if user name is already present in the SQLite database.Like in below code

 private void cname_txt_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            SQLiteConnection sqliteCon = new SQLiteConnection(dbConnectionString);
            // open connection to database 
            try
            {
                sqliteCon.Open();
                string Query = "select * from OwnerDetails where Name='" + cname_txt.Text + "' ";
                SQLiteCommand createCommand = new SQLiteCommand(Query, sqliteCon);
                SQLiteDataReader dr = createCommand.ExecuteReader();
                while (dr.Read())
                {
                    string Name = dr.GetString(0);
                    string Agency = dr.GetString(1);
                    string CellNo = dr.GetString(2);
                    string Office = dr.GetString(3);
                    string Email = dr.GetString(4);
                    string Address = dr.GetString(5);
                    cname_txt.Text = Name;
                    cagency_txt.Text = Agency;
                    ccellno_txt.Text = CellNo;
                    coffice_txt.Text = Office;
                    cemail_txt.Text = Email;
                    caddress_txt.Text = Address;

               }
                sqliteCon.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

But my Application not updating itself from database recent values. I need to close application and then reopen it . Then it will show data in the autocomplete Name textbox. I have tried

this.refresh();
this.dispose();
this.hide();

almost all to main application but main application is not refreshing to new database values I know I need to put any update query in the save button code but I am unable to do that. Your help will be appreciated

Aucun commentaire:

Enregistrer un commentaire