using System;
using System.Data.Common;
using System.Data.SQLite;
class Program
{
static void Main(string[] args)
{
const string databaseName = @"C:\cyber.db";
SQLiteConnection connection =
new SQLiteConnection(string.Format("Data Source={0};", databaseName));
connection.Open();
SQLiteCommand command = new SQLiteCommand("SELECT * FROM 'example';", connection);
SQLiteDataReader reader = command.ExecuteReader();
Console.Write("\u250C" + new string('\u2500', 5) + "\u252C" + new string('\u2500', 60) + "\u2510");
Console.WriteLine("\n\u2502" + " id \u2502" + new string(' ', 30) + "value" + new string(' ', 25)+ "\u2502");
Console.Write("\u251C" + new string('\u2500', 5) + "\u253C" + new string('\u2500', 60) + "\u2524\n");
foreach (DbDataRecord record in reader)
{
string id = record["id"].ToString();
id = id.PadLeft(5 - id.Length, ' ');
string value = record["value"].ToString();
string result = "\u2502" + id + " \u2502";
value = value.PadLeft(60 , ' ');
result += value + "\u2502";
Console.WriteLine(result);
}
Console.Write("\u2514" + new string('\u2500', 5) + "\u2534" + new string('\u2500', 60) + "\u2518");
connection.Close();
Console.ReadKey(true);
}
} |