0

Hi there, i am deeply troubled as my application runs successfully and adds new entry to the table and i can see that via datagridview.

but as soon as the application closes and i check the database all is gone. there is no entry in the database. kindly see my code.

private void btnUpdateEntry_Click(object sender, EventArgs e)
        {
            string update_cmd = "INSERT INTO SMO_Table" + "(field1,field2,field3,field4)" + "VALUES( 36,'ali','11:15','17:40')";

            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\SMO_DB.mdb");

            OleDbCommand aCommand = new OleDbCommand(update_cmd, aConnection);
            
            aConnection.Open();
            
            try
            {
                aCommand.ExecuteNonQuery();
             }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
             aConnection.Close();
            
dataGridView1.Enabled = true;
            this.sMO_TableTableAdapter.Fill(this.sMO_DBDataSet.SMO_Table);

the above code runs successfully but actually there is no entry in the database. why is this so?

Regards,

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by __avd
0

There are two copies of your database. One which is located in project-solution folder and another is at debug\bin folder. The path you mentioned is target to debug\bin folder.

Database file added with project consider as a resource and VS creates a copy of database to the debug\bin folder.

To control such a thing:
1. Select database file from solution explorer
2. Set Copy to output directory property from properties windows.

0

There are two copies of your database. One which is located in project-solution folder and another is at debug\bin folder. The path you mentioned is target to debug\bin folder.

Database file added with project consider as a resource and VS creates a copy of database to the debug\bin folder.

To control such a thing:
1. Select database file from solution explorer
2. Set Copy to output directory property from properties windows.

Thank you problem solved.

there is another request for you how can i lock this database so that no one can change the contents after the program is close.

my idea is to encrypt it.

i am looking for your comments. again thanks for your help

Regards,
Jincom

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.