Using System;
Using System. Collections. Generic;
Using System. Text;
Using FirebirdSql. Data. FirebirdClient;
Namespace CreateDB
{
Class Program
{
Static void Main (string [] args)
{
FbConnection. CreateDatabase (GetConnectionString ());
Using (FbConnection conn = new FbConnection (GetConnectionString ()))
{
Conn. Open ();
Using (FbCommand createTable = conn. CreateCommand ())
{
CreateTable. CommandText = "create table test (id int, word varchar (20) character set win1250 )";
CreateTable. ExecuteNonQuery ();
}
Using (FbCommand insertData = conn. CreateCommand ())
{
InsertData. CommandText = "insert into test values (@ id, @ word )";
For (int I = 0; I <10; I ++)
{
InsertData. Parameters. Clear ();
InsertData. Parameters. Add ("@ id", FbDbType. Integer). Value = I;
InsertData. Parameters. Add ("@ word", FbDbType. VarChar, 20). Value = GetWord (I );
InsertData. ExecuteNonQuery ();
}
}
}
}
Static string GetConnectionString ()
{
FbConnectionStringBuilder cs = new FbConnectionStringBuilder ();
Cs. Database = "test. fdb ";
Cs. UserID = "SYSDBA ";
Cs. Password = "masterkey ";
Cs. Charset = "UTF8 ";
Cs. ServerType = FbServerType. Embedded;
Return cs. ToString ();
}
Static string GetWord (int I)
{
StringBuilder sb = new StringBuilder (I );
For (int j = 0; j <I; j ++)
{
Sb. Append (I );
}
Return sb. ToString ();
}
}
}
Li Xin's Crazy Coding life...