Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.Odbc;
  6. using SharedLib;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string myConnString = @"Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test; User=root;Password=root123;Option=3;";
  15.  
  16. OdbcConnection conn = new OdbcConnection(myConnString);
  17.  
  18.  
  19.  
  20.  
  21. List<BirdInfo> birdInfoList = new List<BirdInfo>();
  22. conn.Open();
  23. OdbcCommand Query = conn.CreateCommand();
  24.  
  25. Query.CommandText = @"SELECT idPhoneTest, Name FROM phonetest";
  26.  
  27. OdbcDataReader myReader = Query.ExecuteReader();
  28.  
  29. while (myReader.Read())
  30. {
  31. BirdInfo birdInfo = new BirdInfo()
  32. {
  33.  
  34. id = (int)myReader.GetDecimal(0),
  35. birdName = myReader.GetString(1)
  36.  
  37. };
  38. Console.WriteLine("Bird id {0} Bird name {1}" , birdInfo.id, birdInfo.birdName);
  39.  
  40. birdInfoList.Add(birdInfo);
  41.  
  42. }
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement