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.Threading.Tasks;
- using MySql.Data;
- using MySql.Data.MySqlClient;
- namespace testi
- {
- class Program
- {
- static void Main(string[] args)
- {
- int luku;
- MySql.Data.MySqlClient.MySqlConnection conn;
- try
- {
- conn = new MySqlConnection("Server=niisku.lamk.fi;uid=kalljuha;pwd=Koodaus1;database=user_kalljuha");
- conn.Open();
- Console.WriteLine("Anna huonetilan minimi henkilömäärä:");
- luku = int.Parse(Console.ReadLine());
- MySqlCommand cmd = new MySqlCommand(string.Format("select * from huonetilat where henkilömäärä >= {0}", luku), conn);
- MySqlDataReader rdr = cmd.ExecuteReader();
- Console.WriteLine();
- Console.WriteLine("Sopivat huonetilat:");
- Console.WriteLine();
- while (rdr.Read())
- {
- Console.WriteLine(rdr[0]);
- }
- if (luku > 40)
- Console.WriteLine("Ei sopivia huonetiloja.");
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement