Click here to Skip to main content
15,918,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building an application a small part of it is, like the timestamp or last login time of user which is displayed on MdiParentForm which is retrived from database(MS Access) and is updated on each login. Its not a big issue but the thing is initially I stored a date in lastlogin column in the MS Access file. Now the problem is whenever I run application from Visual Studio IDE I always see the first date and time I stored in the database. It works perfectly as I saw when I opened the MS Accees file, the database gets updated with each login even when I run the compiled .exe file explicitly it shows updated Date and time of last login. Can't understand whats wrong with running application while building in Visual Studio 2005 IDE. To verify such things I need to explicitly run the compiled .exe. I tried to resolve it by "Clean","Rebuld",etc. from solution explorer but problem persists. How do I get the current value rather than the cached value or initial value. How do I resolve this issue?
Posted
Comments
Sergey Alexandrovich Kryukov 9-May-11 10:52am    
Not clear. Show some code (better create a special simplest code sample) and steps to reproduce the problem.
--SA

Maybe during ur pageload u have included this code thats why when loading it shows the data what if try to make some condition during loading.
 
Share this answer
 
If it is your custom code (i.e. for login) Debug the data retrival code in c# and check if you are getting proper value for example top 1 in descending order for that user and then the login label's text property is updated with same.

By the way when debugging are you getting updated values from database which you are getting on running your complied.exe file?

Thanks,
Hemant
 
Share this answer
 
I finally came to know why I did not see updated timestamp (Last login date and time) but still my problem is not solved.
Actually, I included the database file (MS Access) in my project. Now my connection string is as:

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
        <add name="constr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DATA.mdb" />
    </connectionStrings>
</configuration>


So in connection string the path is not absolute (like C:\SomeFolder\MyDatabasefile.mdb). Moreover I have an app.config file which contains this code so entire project uses same connection string and no chance for two different connectionstrings.
Now my problem is that even the Login is made, the timestamp (Last Login Date and Time) does not change. I observed very strange thing which was its reason. It was that after the Database file (from other location) was included in my project I found a new copy of that database file in my application folder (as normal) along with folders like “bin”, “obj”, ”Properties”, “Resources” and various other .cs files. When my application loaded from Visual Studio IDE it created all necessary files in bin\debug and among these files was also the Database file. So now in my project folder I have two copies of database file. Now the strange part was that when my application loaded from Visual Studio it used the Database file which was present outside bin\debug folder with other .cs files and folders like “bin”, “obj”,”Properties”, etc. and after login successful the Timestamp of that database was shown to me which never updated because the change was always made in the database file present in the bin\debug folder with the compiled .exe file. I was really shock to observe that the database file used to read and write is different. I did not agree that and I confirmed that by making changes in that database file (explicitly opening and making changes in it) which was present outside bin\debug folder with other .cs files, I found that timestamp had change in it. This way I got known reason although strange.
The explicit running of .exe files is perfect but running application from Visual Studio makes such issue which uses one database for reading data and other to write!
I can’t understand reason or logic just think or guess that may be this goes due to not using the absolute path (like C:\SomeFolder\MyDatabasefile) I find two database file access simultaneous.
I can’t see updates in database while building it and each time run .exe file explicitly to check that my coding is perfect or not. I tried using absolute path in connection string like (C:\Somefolder\MyDatabasefile.mdb) which works perfect. So is it I have no other option than to change my connectionstring path type and after completion of project change path type to same as now (relative) or any other solution for it?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900