怎么创建数据库请参考
http://blog.csdn.net/u011511086/article/details/79174680

C#測試firebird嵌入式數據庫demo地址下載
https://pan.baidu.com/s/1dFZvNtZ

此示例demo的csdn下载地址
http://download.csdn.net/download/u011511086/10226084

數據庫下載:
https://www.firebirdsql.org/en/firebird-2-5-8/

.NET驅動下載
https://www.firebirdsql.org/en/additional-downloads/

C#示例代碼
https://www.firebirdsql.org/en/net-examples-of-use/

项目bin目录
这里写图片描述

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();

        }
    }
}

报错解决:

这里写图片描述

这里写图片描述


本文转载:CSDN博客