locked
how can i achieve result like SQLiteDataReader in winrt

    General discussion

  • I am getting result in .net from SQLiteDataReader ,

     using (SQLiteConnection connection = new SQLiteConnection(dbconnection))
                    {
                        if (connection.State != ConnectionState.Open)
                            connection.Open();
                        using (SQLiteCommand cmd = new SQLiteCommand(connection))
                        {
                            cmd.CommandText = SelectQuery; // some random sql query
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
                            {
                                dt.Load(dr);//dt is data table
                            }
                        }
                    }


    so i want to do the same thing in WinRT , currently i am doing like this:

     public static string getJson(string Squery)
            {
                var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyLocalDB.db3");
                using (var db = new SQLite.SQLiteConnection(dbpath))
                {
                    var qu = db.Query<taskPerSon>(Squery);
                    var query = from pro in qu select new { type_id = pro.TYPE_ID, name= pro.NAME };
                    return Newtonsoft.Json.JsonConvert.SerializeObject(query); // return string(JSON)
                }
            }

     here is is returning <taskPerson> type, but i don't want a generic list . I want to create a consolidated method where i can pass SqlQueries and it will return string(json) .

    please help me







    Wednesday, April 16, 2014 1:22 PM

All replies

  • Hello,

    I'm not sure exactly what you are looking for and unfortunately I'm not a SQLite expert but our very own Tim Heuer has a great blog on how to use SQLite in a Windows Store app in both .Net and JavaScript in his blog entry UPDATED HOWTO: SQLite with Windows 8 apps.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, April 17, 2014 1:30 AM
    Moderator
  • I want to create a consolidated method where  i can fire any sqlquery like :
    "select id,name from table1"

    "select emp_id,dept_it,emp_name from emptable" and so on..........

    and get result, i don't want to create a class for each sqluery, like <taskPerSon> i don't want to create generic type for every sqluery..

    Thursday, April 17, 2014 6:11 AM
  • please reply
    Tuesday, April 22, 2014 6:56 AM
  • Hello,

    I'm very sorry but I'm not a SQLite expert. Hopefully someone in the community can give you a detailed answer. You can also try contacting SQLite support.

    http://www.sqlite.org/support.html

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, April 22, 2014 9:05 PM
    Moderator
  • this is not about sqlite this is about .net i want to create consolidate method in winrt(c#).

    regards,

    Wednesday, April 23, 2014 9:36 AM