资源简介
这里的版本firebird2.5.8,demo里面包含测试数据库和必要的支持dll,可直接运行
代码片段和文件信息
using FirebirdSql.Data.FirebirdClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
namespace FirebirdTest
{
class Program
{
static void Main(string[] args)
{
//這裡的fbembed的版本是2.5.8
FbConnectionStringBuilder sb = new FbConnectionStringBuilder();
sb.ServerType = FbServerType.embedded;
//SYSDBA
sb.UserID = “SYSDBA“;
//masterkey
sb.Password = “masterkey“;
sb.Database = AppDomain.CurrentDomain.baseDirectory.Replace(“bin\\Debug\\“ ““) + “DB\\TEST.FDB“;
FbConnection connection1 = new FbConnection(sb.ToString());
connection1.Open();
//事務
FbTransaction tran = connection1.BeginTransaction();
try
{
//插入
FbCommand cmd2 = connection1.CreateCommand();
cmd2.Transaction = tran;
string sql2 = “INSERT INTO USERINFO (ID NAME SPASSWORD) VALUES (@id @name @password)“;
cmd2.CommandText = sql2;
cmd2.Parameters.Add(new FbParameter(“@id“ Guid.NewGuid().ToString()));
cmd2.Parameters.Add(new FbParameter(“@name“ “歐陽修0“));
cmd2.Parameters.Add(new FbParameter(“@password“ “sdf56756“));
int count = cmd2.ExecuteNonQuery();
cmd2.Dispose();
//修改
FbCommand updateCmd = connection1.CreateCommand();
updateCmd.Transaction = tran;
string sql_update = “update USERINFO set NAME=‘小萬1‘ where id=‘700A096E-5B28-7AF7-8D61-C3E0D0FF93FF‘“;
updateCmd.CommandText = sql_update;
int count_up = updateCmd.ExecuteNonQuery();
updateCmd.Dispose();
tran.Commit();
}
catch (Exception ex)
{
tran.Rollback();
}
string sql = “select * from USERINFO“;
FbCommand cmd = new FbCommand(sql connection1);
FbDataAdapter dp = new FbDataAdapter(cmd);
DataTable dt = new DataTable();
dp.Fill(dt);
dp.Dispose();
cmd.Dispose();
connection1.Close();
connection1.Dispose();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-26 16:55 FirebirdTest\
目录 0 2018-01-26 16:28 FirebirdTest\FirebirdTest\
文件 189 2018-01-25 17:13 FirebirdTest\FirebirdTest\App.config
目录 0 2018-01-26 16:12 FirebirdTest\FirebirdTest\DB\
文件 802816 2018-01-26 16:10 FirebirdTest\FirebirdTest\DB\TEST - 副本.FDB
文件 802816 2018-01-26 16:31 FirebirdTest\FirebirdTest\DB\TEST.FDB
目录 0 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\
文件 863744 2018-01-26 12:25 FirebirdTest\FirebirdTest\DLL\FirebirdSql.Data.FirebirdClient.dll
文件 5668352 2018-01-26 13:26 FirebirdTest\FirebirdTest\DLL\fbem
文件 6758 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\fbintl.conf
文件 1100288 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\fbintl.dll
文件 13824 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\fbudf.dll
文件 27661 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\firebird.conf
文件 12800 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\ib_udf.dll
文件 8192 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\ib_util.dll
文件 1558016 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\icudt30.dll
文件 575488 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\icuin30.dll
文件 935936 2018-01-26 14:46 FirebirdTest\FirebirdTest\DLL\icuuc30.dll
文件 3581 2018-01-26 16:30 FirebirdTest\FirebirdTest\FirebirdTest.csproj
文件 228 2018-01-26 13:53 FirebirdTest\FirebirdTest\FirebirdTest.csproj.user
文件 2510 2018-01-26 16:28 FirebirdTest\FirebirdTest\Program.cs
目录 0 2018-01-25 17:13 FirebirdTest\FirebirdTest\Properties\
文件 1332 2018-01-25 17:13 FirebirdTest\FirebirdTest\Properties\AssemblyInfo.cs
目录 0 2018-01-26 14:36 FirebirdTest\FirebirdTest\bin\
目录 0 2018-01-26 15:49 FirebirdTest\FirebirdTest\bin\Debug\
文件 863744 2018-01-26 12:25 FirebirdTest\FirebirdTest\bin\Debug\FirebirdSql.Data.FirebirdClient.dll
文件 6656 2018-01-26 16:30 FirebirdTest\FirebirdTest\bin\Debug\FirebirdTest.exe
文件 189 2018-01-25 17:13 FirebirdTest\FirebirdTest\bin\Debug\FirebirdTest.exe.config
文件 13824 2018-01-26 16:30 FirebirdTest\FirebirdTest\bin\Debug\FirebirdTest.pdb
文件 22688 2018-01-26 16:31 FirebirdTest\FirebirdTest\bin\Debug\FirebirdTest.vshost.exe
文件 189 2018-01-25 17:13 FirebirdTest\FirebirdTest\bin\Debug\FirebirdTest.vshost.exe.config
............此处省略26个文件信息
评论
共有 条评论