Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using Microsoft.SPOT;
  4. using GHI.SQLite;
  5. public class Program
  6. {
  7. public static void Main()
  8. {
  9. Database myDatabase = new GHI.SQLite.Database();
  10. myDatabase.ExecuteNonQuery("CREATE Table tblGauges" +
  11. " (ID INTEGER, GaugeText TEXT, MaxValue INTEGER, MinValue INTEGER, UpdateRate INTEGER, Units TEXT, ARBFilter INTEGER)");
  12. //add rows to table
  13. myDatabase.ExecuteNonQuery("INSERT INTO tblGauges (ID, GaugeText, MaxValue, MinValue, UpdateRate, Units, ARBFilter)" +
  14. " VALUES (1,'RPM', 8000, 0, 25, 'RPM', 201)");
  15. myDatabase.ExecuteNonQuery("INSERT INTO tblGauges (ID, GaugeText, MaxValue, MinValue, UpdateRate, Units, ARBFilter)" +
  16. " VALUES (2,'TPS', 100, 0, 25, '%', 201)");
  17. myDatabase.ExecuteNonQuery("INSERT INTO tblGauges (ID, GaugeText, MaxValue, MinValue, UpdateRate, Units, ARBFilter)" +
  18. " VALUES (3,'ECT', 140, -40, 1000, 'oC', 1217)");
  19.  
  20. // Process SQL query and save returned records in SQLiteDataTable
  21. ResultSet result = myDatabase.ExecuteQuery("SELECT * FROM tblGauges WHERE ID = 2");
  22. // Get a copy of table data example
  23. ArrayList tabledata = result.Data;
  24.  
  25. object obj;
  26. String row = "";
  27. for (int j = 0; j < result.RowCount; j++)
  28. {
  29. row = j.ToString() + " ";
  30. for (int i = 0; i < result.ColumnCount; i++)
  31. {
  32. obj = result[j, i];
  33. if (obj == null)
  34. row += "N/A";
  35. else
  36. row += obj.ToString();
  37. row += " |";
  38. }
  39. Debug.Print(row);
  40. }
  41. myDatabase.Dispose();
  42. while (true) { }
  43. }
  44. }
  45.  
  46. ---------------------------------------------
  47. OUTPUT:
  48. Key, ID, Text, Max, Min, Unit, ARBFilter (int)
  49.  
  50. 0 2 |TPS |100 |0 |25 |% |201 |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement