fork download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Data;
  7. using MySql;
  8. using MySql.Data;
  9. using MySql.Data.MySqlClient;
  10. using MySql.Data.Types;
  11.  
  12. namespace MySqlGeoType
  13. {
  14. class MySqlGear
  15. {
  16. private const string conString = "Server = localhost; User Id = root; Password = ****; Database = osm;";
  17. private MySqlConnection connection { get; set; }
  18.  
  19. public MySqlGear()
  20. {
  21. try
  22. {
  23. this.Open();
  24. }
  25. catch (Exception exc)
  26. {
  27. Console.WriteLine(exc);
  28. }
  29. }
  30.  
  31. internal MySqlConnection Open()
  32. {
  33. connection = new MySqlConnection(conString);
  34. connection.Open();
  35. if (connection.State == ConnectionState.Open) return connection;
  36. else return null;
  37. }
  38.  
  39. internal MySqlConnection Open(string inputConString)
  40. {
  41. if (inputConString != String.Empty) connection = new MySqlConnection(inputConString);
  42. else connection = new MySqlConnection(conString);
  43. connection.Open();
  44. if (connection.State == ConnectionState.Open) return connection;
  45. else return null;
  46. }
  47.  
  48. internal MySqlDataReader SendQuery()
  49. {
  50. if (connection.State == ConnectionState.Open)
  51. {
  52. MySqlCommand cmd = new MySqlCommand("SELECT AsWKT(object) as 'object' FROM geo.data", connection);
  53. var reader = cmd.ExecuteReader();
  54. return reader;
  55. }
  56. else return null;
  57. }
  58. }
  59.  
  60. class Program
  61. {
  62. static void Main()
  63. {
  64. try
  65. {
  66. MySqlGear gear = new MySqlGear();
  67. var reader = gear.SendQuery();
  68.  
  69. if (reader.HasRows)
  70. {
  71. while (reader.Read())
  72. {
  73. //var polygon = (byte[])reader["object"];
  74. //var obj = new MySqlGeometry(MySqlDbType.Blob, polygon);
  75. var polygon = reader["object"].ToString();
  76. var obj = MySqlGeometry.Parse(polygon);
  77. }
  78. }
  79. }
  80. catch (Exception exc)
  81. {
  82. Console.WriteLine(exc);
  83. }
  84.  
  85. Console.ReadLine();
  86. }
  87. }
  88. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(6,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(7,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(8,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(9,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(10,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(31,18): error CS0246: The type or namespace name `MySqlConnection' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(39,18): error CS0246: The type or namespace name `MySqlConnection' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(48,18): error CS0246: The type or namespace name `MySqlDataReader' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 8 error(s), 0 warnings
stdout
Standard output is empty