Zaid Al Shattle
Zaid Al Shattle

Reputation: 1534

Access database acting randomly and inconsistently after being updated with OLEDB c#

So I am having a very weird issue, At first my code to insert items into my access database stopped working, it is a simple code like this:

using (OleDbConnection myCon = new OleDbConnection())
            {
                OleDbCommand cmd = new OleDbCommand()
                {
                    CommandType = CommandType.Text,
                    CommandText = "insert into applicationSalts ([appName],[salt]) values (?,?)"
                };
                cmd.Parameters.AddWithValue("@appName", appName);
                cmd.Parameters.AddWithValue("@salt", salt);
                myCon.ConnectionString = publicDbConnectionString;
                cmd.Connection = myCon;
                myCon.Open();
                int result = cmd.ExecuteNonQuery();
                myCon.Close();
            }

So it is very straight forward, inserting those values and I checked that result = 1 (query finished successfully).

Now it gets a bit weird, The database happens to not show any new values. Which is weird, Then I tried renaming the database and then all those records appear later! I tried using the database from another location (I was using it from C:/databaseName then now used it from D:/databaseName) then it worked. I moved the database file that worked back into C, then suddenly the records that appeared before disappeared.

Much weirder is that at the beginning one of the tables in the same database used to be working with an ideantical call as the one prior to this. But this one didnt! Then when I was trying to find the issue that one also stopped working..

Also after I manually changed some records when it was working through ms access it later ignored the changes..

I am slowly going insane as I am not really understanding what is going on, This is using access 2000 file format.

Edit: After further experimentation it is still getting weirder for me, While the file is called onlineDb.mdb it had a single record, deleting that made it disappear, Now renaming it to onDb.mdb made that record come back, adding other records that were missing. Then renaming to onlineDB.mdb again made all records disappear.

Upvotes: 0

Views: 51

Answers (0)

Related Questions