开发者

LocalDataCache in C#.net

I am using Lo开发者_开发问答cal data Cache (.sdf) in my application. I want to store data locally. How to do that. thereafter i will sync local data with online data. How should i make connection to local database(.sdf) and saving records in it.


Use database like this:

string localDatabasePath = @"FOLDER";
string localDatabaseName = "FILE.sdf";
string localDatabasePass = "WhyDoYouCare";
string localDatabaseUsersTable = "userstable";

                SqlCeConnection localDatabaseConn = new SqlCeConnection("Data Source = " + localDatabasePath + "\\" + localDatabaseName + "; Password=" + localDatabasePass);
                localDatabaseConn.Open();
                SqlCeCommand localDatabaseCmd = localDatabaseConn.CreateCommand();
                localDatabaseCmd.CommandText = "SELECT something FROM " + localDatabaseUsersTable + " WHERE username='" + Username + "'";
                localDatabaseCmd.ExecuteNonQuery();
                SqlCeDataReader localDatabaseRdr = localDatabaseCmd.ExecuteReader();

Use Smart Client Software Factory for disconnected architecture and synchronization. For updating to central database when connected to network, you will have to write web-service usually and update data objects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜