![]() We will achieve this using the SQLiteCommand object. Next, we need to create a table and populate data. It also sets the initial visibility state of the other UI controls on the page. The above code will ensure to open the connection only when a connection object does not exist. MySQLiteDB = new SQLiteConnection( "MyTestDB") private void buttonOpen_Click( object sender, RoutedEventArgs e) Now, we can add code to establish the connection to the SQLite database under the click event handler for the button “Create/Open”. SQLiteConnection mySQLiteDB = null // Constructor public MainPage() public partial class MainPage : PhoneApplicationPage But before we do that, we need to add a variable of type SQLiteConnection, which we will use in the application. Now we need to add the event handler for the button click events. In the code behind for MainPage.xaml (the file ), add the following line to make the SQLite library available on the page. The file should be in the temporary location we mentioned above. Now, add the SQLite client file as a reference from the project settings. On the MainPage.xaml file, add four button controls titled, (a) “Create/Open”, (b) “Populate”, (c), “Clear”, and (d) “Close”. When prompted for the target Windows Phone OS version, select WP OS7.1 Now Create a Visual Studio project called “WLSQLiteDemo” of type Windows Phone application, from the available templates under Silverlight for Windows Phone, under Visual C#. Copy the binary file “.dll” to a temporary location. Open the downloaded code and compile the code for the SQLite Client for Windows Phone. SQLite on Windows Phone uses the feature of isolated storage as is data repository. When you extract the contents of the download, you will notice that it contains 2 Visual Studio Projects, (a) (which contains the code for the wrapper), and (b) a test project CSharpSqlite.TestProject (which contains test code).įor application developers targeting local database support, the binary, which is compiled from the project “” is necessary. The download (available under the LGPL license) includes the source code. The SQLite client for Windows Phone is available at Īt the time of writing the article, version 0.6.1 was available (download link is ). Fortunately for us, open source efforts from the developer community delivered support for SQLite to the Windows Phone, allowing the platform to have local database support before it was officially launched in Windows Phone Mango. Many useful things, like copy/paste, were missing another notable absentee feature was support for a local database.Īpplication developers were expected to use server-side databases to achieve their desired results. In the rush to get the first version of Windows Phone out, Microsoft did not include a lot of features in the initial launch of the Windows Phone platform.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |