Skip to content

Instantly share code, notes, and snippets.

@kowill
Created April 20, 2016 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kowill/f86ea4efdec4b9e2ca54b9fbeb658c32 to your computer and use it in GitHub Desktop.
Save kowill/f86ea4efdec4b9e2ca54b9fbeb658c32 to your computer and use it in GitHub Desktop.
20160420Firebird3.0
using FirebirdSql.Data.FirebirdClient;
using System;
using System.IO;
namespace Fb3Test
{
class Program
{
static void Main(string[] args)
{
var builder = new FbConnectionStringBuilder();
builder.DataSource = "localhost";
builder.Database = @"D:\DB\FB3TEST.FDB";
builder.Charset = FbCharset.Utf8.ToString();
builder.UserID = "SYSDBA";
builder.Password = "masterkey";
builder.ServerType = FbServerType.Embedded;
builder.ClientLibrary = "fbclient";
builder.Pooling = false;
if (!File.Exists(builder.Database))
{
FbConnection.CreateDatabase(builder.ConnectionString);
}
using (var con = new FbConnection(builder.ConnectionString))
using (var command = con.CreateCommand())
{
con.Open();
command.CommandText = @"recreate table Test (id int, price int, name varchar(50), hoge boolean, primary key (id))";
command.ExecuteNonQuery();
command.CommandText = @"insert into Test values (1,500, 'Hoge', true)";
command.ExecuteNonQuery();
command.CommandText = @"insert into Test values (2,200, 'HogeHoge', false)";
command.ExecuteNonQuery();
command.CommandText = @"insert into Test values (3,12000, 'あいうえお', true)";
command.ExecuteNonQuery();
command.CommandText = @"select rank() over (order by price desc) as rank, id, price, name, hoge from test";
var reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine($"{reader[0]} {reader[1]} {reader[2]} {reader[3]} {reader[4]}");
}
}
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment