Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.Odbc;
- using SharedLib;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string myConnString = @"Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test; User=root;Password=root123;Option=3;";
- OdbcConnection conn = new OdbcConnection(myConnString);
- List<BirdInfo> birdInfoList = new List<BirdInfo>();
- conn.Open();
- OdbcCommand Query = conn.CreateCommand();
- Query.CommandText = @"SELECT idPhoneTest, Name FROM phonetest";
- OdbcDataReader myReader = Query.ExecuteReader();
- while (myReader.Read())
- {
- BirdInfo birdInfo = new BirdInfo()
- {
- id = (int)myReader.GetDecimal(0),
- birdName = myReader.GetString(1)
- };
- Console.WriteLine("Bird id {0} Bird name {1}" , birdInfo.id, birdInfo.birdName);
- birdInfoList.Add(birdInfo);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement