C 操作FireBird 火鳥 資料庫

2021-08-28 20:52:37 字數 2526 閱讀 6126

連線火鳥資料庫分兩種方式:

(1)伺服器方式  

本地裝有firebird資料庫,這種方式相對簡單一些,只用到乙個類(firebirdsql.data.firebirdclient)就好;

(2)嵌入式方式

本地無須裝firebird資料庫,但是需要引用一堆檔案(說實話我也搞不清哪些要、哪些不要),如下圖:

具體**實現:

using system;

using system.collections.generic;

using system.data;

using system.linq;

using system.text;

using firebirdsql.data.firebirdclient;

using firebirdsql.data.services;

namespace dc.dbhelp.firebird

/// /// 伺服器式連線

///

///

///

private string getconnstring_server()

/// /// 嵌入式連線

///

///

///

private string getconnstring_client()

\\fbembed.dll";

cs.userid = "sysdba";

cs.password = "masterkey";

cs.database = _path;

cs.charset = "utf8";

cs.servertype = fbservertype.embedded;

return cs.tostring();

}private void myopen()

private void myclose()

/// /// 資料庫連線測試 (鏈結目標庫)

///

///

/// 連線失敗時的異常資訊

///

public bool connecttest(out string errinfo)

catch (exception ex)";}

return string.isnullorempty(errinfo);

}public dataset executesqlgetds(string sql)

public datatable executesqlgetdt(string sql,int toprows)

/// /// 執行sql,返回受影響的行數

///

public int executenonquery(string sql, int timeout = 5)

/// /// get the list of user tables

/// table_catalog, table_schema, table_name, table_type

///

///

public datatable gettablenamelist_user()

);myclose();

if (dta != null)

return dt;

}return null;

}/// /// get the list of system tables

/// table_catalog, table_schema, table_name, table_type

///

///

public datatable gettablenamelist_sys()

);myclose();

return dta;

}/// /// get table columns

/// table_name,column_name,column_data_type,column_size,ordinal_position

///

///

///

public datatable getcolumninfo(string tablename = "")

): _conn.getschema("columns", new string );

myclose();

return dta;

}/// /// 資料庫還原

///

/// 檔案路徑

public void restoredb(string pathbak)

catch (exception ex)

}/// /// 資料庫備份

///

/// 檔案路徑

public void backupdb(string pathbak)

catch (exception ex)}}

}

Firebird簡易上手操作

1 啟動命令列模式。進入安裝目錄firebird 2 5 bin isql回車。顯示 use connect or create database to specify a database 表示連線成功。2 在d data目錄下建立乙個名為test.fdb的資料庫 sql create datab...

火鳥資料庫開發筆記

1 建立類似oralce的sys guid set term create or alter procedure sys guid returns hex uuid varchar 32 asdeclare variable i integer declare variable c integer ...

MSSQL資料庫轉到FIREBIRD資料庫的問題

我是fb新手,在我的原mssql 中,存在依賴於區域性臨時表 注意是區域性而不是全域性 的操作,現在轉到fb了怎麼辦?而且,為效能計,我還用到了mssql裡面的表變數型別 從mssql的自定義函式裡返回表變數 這可怎麼辦啊?大家給我出出主意!另外,在mssql裡面的語句 1 select into ...