none
Searching Using sqlite C# RRS feed

  • Question

  • Hello,

    I have been working on the Travelling route by cabs, buses, trains etc. I have inserted the comboboxes to search for the routes information. I want to display the routes when i click the submit according the user requirement entered in the comboboxes. I am using sqlite local Database. The problem now is how to integrate the search button using Database to search the route information. If anyone can post the code, it will be a huge help for me. 

    Thanks & Regards

    Manideep

    Orbit Technology Research Limited


    manideep

    Thursday, September 18, 2014 4:52 AM

Answers

  • Hi Mummadi,

    >The problem now is how to integrate the search button using Database to search the route information.

    It’s hard to describe the structure of the sqlite database to you, because I don’t know your app requirement of travelling route. So what I can do is to let you how to query and retire information from sqlite according the parameter from comboboxes in windows phone. You don’t mention the windows phone os version you are using. Please choose the appropriateversion of windows phone development to download the sqlite library and install in your computer.

    For windows phone Runtime, see SQLite for Windows Runtime 8.1.

    For windows phone Silverlight, see SQLite for Windows silverlight Phone 8.1.

    For windows phone 7, see SQLite for WP7.

    I build a simple project to show how to get input from combobox and then query into sqlite to retire the route information. Of course, this is a demo, you need to modify them to meet your requirement.

    In XAML:

    <StackPanel>
    
                <ComboBox x:Name="StartRoad">
    
                    <ComboBoxItem Content="111111" ></ComboBoxItem>
    
                </ComboBox>
    
                <ComboBox x:Name="EndRoad">
    
                    <ComboBoxItem Content="2222222" ></ComboBoxItem>
    
                </ComboBox>
    
                <Button x:Name="ben" Click="CalculateRoute_Click" Content="calculate route"></Button>
    
            </StackPanel>

    In C#:

    private void CalculateRoute_Click(object sender, RoutedEventArgs e)
    
            {
    
                //build connection to sqlite
    
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "TravellingRoute.db"), true);
    
                //query data according to combobox selected value
    
                var query = conn.Table<TravellingRoute>().Where(x => x.Start == StartRoad.SelectedValue && x.End == EndRoad.SelectedValue);
    
                //retire information and do what you want
    
                var result = await query.ToListAsync();
    
                foreach (var item in result)
    
                {
    
                }
    
            }

    If you still have questions about how to make it work, please post more information about your problem or a test project here.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, September 19, 2014 10:22 AM
    Moderator
  • Hi Mummadi,

    There is no need to use two OnNavigatedTo method, you should merge them to one method. What is the usage of “if (combBox2==combBox3)”? I cannot understand. Here is code example showing how to open sqlite connection and execute sql query. http://developer.nokia.com/community/wiki/How_to_use_SQLite_in_Windows_Phone.

    If you still don’t know how to, please use your OneDrive and share a link here. I will look into it and show you how.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 30, 2014 7:58 AM
    Moderator

All replies

  • Hello,

    I have been working on the Travelling route by cabs, buses, trains etc. I have inserted the comboboxes to search for the routes information. I want to display the routes when i click the submit according the user requirement entered in the comboboxes. I am using sqlite local Database. The problem now is how to integrate the search button using Database to search the route information. If anyone can post the code, it will be a huge help for me. 

    Thanks & Regards

    Manideep

    Orbit Technology Research Limited


    manideep

    Thursday, September 18, 2014 8:53 AM
  • Hi Mummadi,

    >The problem now is how to integrate the search button using Database to search the route information.

    It’s hard to describe the structure of the sqlite database to you, because I don’t know your app requirement of travelling route. So what I can do is to let you how to query and retire information from sqlite according the parameter from comboboxes in windows phone. You don’t mention the windows phone os version you are using. Please choose the appropriateversion of windows phone development to download the sqlite library and install in your computer.

    For windows phone Runtime, see SQLite for Windows Runtime 8.1.

    For windows phone Silverlight, see SQLite for Windows silverlight Phone 8.1.

    For windows phone 7, see SQLite for WP7.

    I build a simple project to show how to get input from combobox and then query into sqlite to retire the route information. Of course, this is a demo, you need to modify them to meet your requirement.

    In XAML:

    <StackPanel>
    
                <ComboBox x:Name="StartRoad">
    
                    <ComboBoxItem Content="111111" ></ComboBoxItem>
    
                </ComboBox>
    
                <ComboBox x:Name="EndRoad">
    
                    <ComboBoxItem Content="2222222" ></ComboBoxItem>
    
                </ComboBox>
    
                <Button x:Name="ben" Click="CalculateRoute_Click" Content="calculate route"></Button>
    
            </StackPanel>

    In C#:

    private void CalculateRoute_Click(object sender, RoutedEventArgs e)
    
            {
    
                //build connection to sqlite
    
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "TravellingRoute.db"), true);
    
                //query data according to combobox selected value
    
                var query = conn.Table<TravellingRoute>().Where(x => x.Start == StartRoad.SelectedValue && x.End == EndRoad.SelectedValue);
    
                //retire information and do what you want
    
                var result = await query.ToListAsync();
    
                foreach (var item in result)
    
                {
    
                }
    
            }

    If you still have questions about how to make it work, please post more information about your problem or a test project here.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, September 19, 2014 10:22 AM
    Moderator
  • Hello Herro wong,

    I am uploading a screenshot of my requirement. I have kept 2 comboboxes and inserted the data through data binding. When i click the submit button it should display the values related  to that items selected in the combo boxes. please post code related to the validations required for me to display the routes either from database or through statically inserted data.

    Regards

    Manideep

    Orbit Technology Research Limited

     


    manideep

    Monday, September 22, 2014 6:31 AM
  • Hello Herro wong,

    I am uploading a screenshot of my requirement. I have kept 2 comboboxes and inserted the data through data binding. When i click the submit button it should display the values related  to that items selected in the combo boxes. please post code related to the validations required for me to display the routes either from database or through statically inserted data.

    Regards

    Manideep

    Orbit Technology Research Limited


    manideep

    Tuesday, September 23, 2014 5:02 AM
  • Hi Mummadi,

    There is no need to use two OnNavigatedTo method, you should merge them to one method. What is the usage of “if (combBox2==combBox3)”? I cannot understand. Here is code example showing how to open sqlite connection and execute sql query. http://developer.nokia.com/community/wiki/How_to_use_SQLite_in_Windows_Phone.

    If you still don’t know how to, please use your OneDrive and share a link here. I will look into it and show you how.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 30, 2014 7:58 AM
    Moderator