VFP 愛用者社區 首頁 VFP 愛用者社區
本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
 
 常見問題常見問題   搜尋搜尋   會員列表會員列表   會員群組會員群組   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入

免費關聯式資料庫FireBird(推薦)
前往頁面 1, 2  下一頁
 
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區
上一篇主題 :: 下一篇主題  
發表人 內容
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 1 樓

發表發表於: 星期日 七月 20, 2003 12:27 am    文章主題: 免費關聯式資料庫FireBird(推薦) 引言回覆

[推薦]免費資料庫FireBird,可代替SQL Server/MySQL/PostgreSQL?

評語:
FireBird源自BORLAND的InterBase 6 Open Source版本
簡述性能如下:
1、有免費版本/簡單易用/運作穩定/維護成本低/簡單快速的安裝
2、跨平臺、多種網路協定。
Win2000/WinNt/WinMe/Win9.X/Unix/Solaris/Novell/Aix/Linux
TCP/IP、具名管道、NetBEUI
3、具備關聯資料庫都有的功能,包括DataBase、Table、Row、Index、View、Sps、Trigger、Default、Roles、約束等
4、SQL語法與SQL92標準一致的
5、優秀的第三方DBA管理工具IBExpert、EMS QuickDesk、IBAdmin等,類似SQL Server資料庫管理員


看完是否想要,動手試試看
鄭重建議,開發環境順序:Win2000>WinXP>Win98



0>客戶實績(不要懷疑)
@美國波士頓證券交易所使用Interbase來處理證券交易資訊.
@文中資訊--使用Interbase來開發會計交易軟件.
http://www.gtcl.net/
@傲林資訊--使用FireBird來開發中小企業軟件.
http://www.gtcl.net/
@速達軟件--使用InterBase來開發中小企業軟件.
http://www.sde2.net/



1>
FireBird版本是由InterBase演變的,所以要按照borland的版權宣告
對於是否免費的,不放心的人可到網址查看
InterBase Public License
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_ipl



2>FireBird相關快速下載網址(測試環境:Win2000/WinXP/Win98)
底下的工具,就已足夠了,不用花心思去網站找,有新的,會告知各位^_^
若Win98/WinMe要當做伺服器的話,請改裝InterBase6
Win2000/WinXP可安裝FireBird或者是InterBase
FireBird資料庫 http://vfp.sunyear.com.tw/download.php?id=237
InterBase資料庫 http://www.3asoft.com/files/ibfb/interbase/ib6os.rar
ODBC驅動程式 http://vfp.sunyear.com.tw/download.php?id=236
IbExpert工具 http://www.hksoftware.net/download/ibep_2.5.0.56_full.exe
DBTools備份精靈 http://vfp.sunyear.com.tw/download.php?id=196
書籍(繁) http://vfp.sunyear.com.tw/download.php?id=189
書籍(簡) http://www.3asoft.com/cn/download/InterBase/ib70guide.zip
FireBird快速安裝手冊(英) http://vfp.sunyear.com.tw/download.php?id=215
FireBird1.5使用手冊 http://vfp.sunyear.com.tw/download.php?id=243



3>如何利用VFP開發,相關技術網址
建立C/S機制 http://vfp.sunyear.com.tw/viewtopic.php?t=368&highlight=sql
CursorAdapter http://vfp.sunyear.com.tw/viewtopic.php?t=378&highlight=sql
Oracle http://vfp.sunyear.com.tw/viewtopic.php?t=120&highlight=sql
SPT http://vfp.sunyear.com.tw/viewtopic.php?t=46&highlight=sql

SPT http://shhuachen.vicp.net/boe/article/doc_019a.htm


4>相關訊息網站
Borland Interbase http://www.borland.com/interbase/
InterBase World http://www.interbase-world.com/
InterBase Installation http://ibinstall.defined.net/
龍豪軟件 http://www.3asoft.com/cn/
IBExpert工具 http://www.ibexpert.com/
FireBird官方站 http://firebird.sourceforge.net/
IBPhoenix http://www.ibphoenix.com/
sibprovider http://www.sibprovider.com/en_us/default.asp
SQL Server 轉換到 Firebird http://www.3asoft.com/cn/showarticle.php?id=109


5>
IB6與MS-SQL7.0作的比較(轉貼)
http://vfp.sunyear.com.tw/viewtopic.php?t=68&highlight=sql
放棄您的桌上型資料庫(DBF,Access, Paradox)(轉貼)
http://vfp.sunyear.com.tw/viewtopic.php?t=69&highlight=sql

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################


Ruey 在 星期一 十月 13, 2003 3:26 am 作了第 54 次修改
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 2 樓

發表發表於: 星期六 八月 02, 2003 12:51 am    文章主題: 引言回覆

FirebirdV1.5 Embedded Server

1>很有意思,可以以本地庫方式使用。
看看它的說明:
1、註冊表
無需使用註冊,庫檔的目錄就是內置伺服器的目錄。
2、資料訪問
只能本地使用,內置伺服器不支援遠端存取的協定,連localhost都不能使用。
3、許可權與安全
安全資料檔案security.fdb沒有使用,也不需要它了。所有本地用戶都可以訪問資料庫。
但是注意, SQL的執行許可權仍會被檢查
4、相容性
你可以同時運行多個使用內置伺服器版本的應用程式,而不會有衝突。 有IB/FB伺服器版的應用程式也一樣不會有問題。但是對於使用內置伺服器版本的應用程式,不要多個應用程式同時訪問一個資料檔案,因為內置伺服器版的程式結構與伺服器版一樣,但是它使用獨佔鎖來訪問資料庫。
用法:
複製gds32.dll和fbembed.dll(注意是內置伺服器版本的)到應用程式目錄下,把fbembed.dll改名為fbclient.dll然後就可以直接訪問firebird的資料庫檔了。( 直接改為gds32.dll也可以Wink
如果需要使用一些外部庫的支持,比如:INTL 支援函式庫 (fbintl.dll) 或 UDF庫,必須把它們分別放在各自的目錄,就象伺服器版一樣,然後設置好firebird.conf檔中的 RootDirectory為內置伺服器版的所在目錄即可。
下面是一個例子,
使用內置伺服器版的應用程式的檔結構如下:
/my_app/app.exe
/my_app/gds32.dll
/my_app/firebird.conf
/my_app/fb/firebird.msg
/my_app/fb/intl/fbintl.dll
/my_app/fb/udf/fbudf.dll
firebird.conf檔的內容:
RootDirectory = /my_app/fb

2> 需要注意的是,最好使用
http://sourceforge.net/project/showfiles.php?group_id=9028&release_id=152919

上正式發佈的版本,不然的話,可能存在無法正常使用的可能。


3>
我的新版<中國成語大全>使用的就是 Embedded Server.不用安裝InterBase or FireBird 伺服器,直接COPY使用,看起來有一點"綠色"的味道了.
下載地址:
http://www.3hinfo.com/cn/products/idiom/idiom.zip

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
elleryq



註冊時間: 2007-06-21
文章: 768


第 3 樓

發表發表於: 星期一 八月 04, 2003 9:21 am    文章主題: 引言回覆

Ruey 兄,你有試過 embedded server 嗎??
我目前只試過正常版本 + .Net Data Provider 而已~
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 4 樓

發表發表於: 星期一 八月 04, 2003 9:55 am    文章主題: 引言回覆

1.下載<中國成語大全>,發覺到竟有這樣的用處,他非常的方便又簡單耶

2.embedded server ,我VFP還未試出來

猜想若真要用VFP,可能要直接透過API方式
與之溝通了喔

或者簡單點的話,使用Delphi/C++

3.如果你有使用的心得也告訴我

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
elleryq



註冊時間: 2007-06-21
文章: 768


第 5 樓

發表發表於: 星期二 八月 05, 2003 9:15 am    文章主題: 引言回覆

ok, 我有空會試試~~
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 6 樓

發表發表於: 星期三 八月 06, 2003 4:07 pm    文章主題: 引言回覆

1.如何通過指令方式瀏覽SQLServer資料庫中包含哪些資料表?
select name from sysobjects where xtype='U'


2.如何通過指令方式瀏覽InterBase/FireBird資料庫中包含哪些資料表?

Select RDB$RELATION_NAME from RDB$RELATIONS where RDB$VIEW_BLR is NULL ORDER BY RDB$RELATION_NAME

如果不帶系統表
Select RDB$RELATION_NAME from RDB$RELATIONS where RDB$VIEW_BLR is NULL and RDB$SYSTEM_FLAG = 0 ORDER BY RDB$RELATION_NAME

或者

SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE SUBSTR(RDB$RELATION_NAME,1,3)<>'RDB' AND SUBSTR(RDB$RELATION_NAME,1,3)<>'IBE' ORDER BY RDB$RELATION_NAME




3.如何取得前幾名的資料
select first 1 skip 1000 * from yourtable
select first 1000 * from yourtable
.

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 7 樓

發表發表於: 星期五 八月 29, 2003 11:15 am    文章主題: 引言回覆

Null to Zero conversion

With Fb1.5 - use COALESCE, which can do an IsNull.

Or use an UNION with:

CAST(NULL as <datatype of your column>)

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
elleryq



註冊時間: 2007-06-21
文章: 768


第 8 樓

發表發表於: 星期二 九月 09, 2003 11:48 am    文章主題: 引言回覆

Firebird on Linux

版本與環境
==========
Firebird: 1.0
OS: Red Hat Linux 9.0

安裝
====
請先連結到 http://sourceforge.net/project/showfiles.php?group_id=9028 這個網址
準備下載 RPM(For Red Hat, SuSE, Mandrake) 或 tarball(For any distribuation) 包.
這裡你會看到有兩個檔案
一個是 FirebirdCS-x.y.z.nnnn-xx.ixxx.rpm
一個則是 FirebirdSS-x.y.z.nnnn-xx.ixxx.rpm
這兩個有什麼差別呢??
所謂的 CS 就是 Classic, 較傳統的,之前,Firebird 都是掛在 inetd, xinetd 下,做為網路服務的
也就是 inetd / xinetd 負責傾聽網路是否有需求,有需求,再把 Firebird 叫起來,將需求轉交給 Firebird.
SS 則是 SuperServer, 啟動時就是獨立起來傾聽網路需求,如果有需求,自己就出來服務這個需求.
在官方網站裡面有對此作詳細的比較與說明.http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_ss_vs_classic
依據此文件,它是說 SuperServer 效率較好.
在這裡我選擇了 CS 版本的 RPM 來安裝.原因我會在"安全性議題"一節再說明.
接下來就是安裝啦.
RPM 版本就用 rpm -ivh FirebirdCS-x.y.z.nnnn-xx.ixxx.rpm
tarball 版本就先用 tar xzf Firebird-x.y.z.nnnn.src.tar.gz 解開,進入該目錄後,再執行 ./install.sh 即可
如果你是用 RPM 安裝的話,安裝以後的檔案都會放在 /opt/interbase 下.


管理
====
管理上,你可以從遠端用 GUI 的管理介面來管理.
也可以使用 Firebird 內附的 isql, gsec 來管理.
gsec 主要用來變更啟動密碼以及增加使用者等等的,除此之外,
Firebird 有提供一個不錯的 script 來幫助你變更啟動密碼.
指令名稱是: /opt/interbase/bin/changeDBAPassword.sh
只要依照指示即可,但有時會失敗,需要手動修改,這時候就要用到 gsec,步驟:
1. /opt/interbase/bin/gsec
2. > modify SYSDBA -pw your_password
3. > quit
4. 如果是用 SS 安裝的話,那麼你得要修改 /etc/init.d/firebird, 找到 ISC_PASSWORD, 修正之;用 CS 的話,請跳到下個步驟
5. 修改 SYSDBA.password, 基本上只要修改第二行即可.
6. 大功告成~
isql 則是 console 模式的管理工具,你可以使用 select / insert / delete / create database ....等等的SQL敘述來作管理.
也可以輸入 help 來看看你可以使用什麼指令.


安全性議題
==========
雖然是一套發展了很久的 Database,但是在我看來,他的安全性有待加強~
首先是 /etc/init.d/firebird 與 /opt/interbase/SYSDBA.password, 密碼以明碼形式存放在檔案中, 如果權限沒設為 root only 的話,密碼很容易被竊取,長度也不能超過8碼(真懷疑預設的密碼masterkey怎麼設進去的).
再來就是設定中,缺少網路控制的設定,也就是無法指定此 server 僅限哪個網段的人使用,也不支援 SSL 之類的設定,如此一來我就不太敢用 SS 來安裝了.
因為這些因素,所以我安裝 CS.我自己的設定大致如下:
1.增加一個名為 firebird 的 user (useradd firebird),此動作同時會增加一個 firebird 的群組.
2.將 /opt/interbase 的所有檔案的 owner 改為 firebird (chown -R firebird:firebird /opt/interbase)
3.修改 /etc/xinetd.d/firebird,在大括號裡面加上
user=firebird
only_from=192.168.0.0 127.0.0.1
以避免使用 root 權限,並允許 192.168.0.0 這個網段以及本機可以使用這個服務.本來打算要使用 tcpwrapper 來作控制的,如此一來就可以使用 /etc/hosts.allow 和 /etc/hosts.deny 來作控制.但是我加上去之後卻會無法連結,只好作罷.
找到 xinetd 的 pid,並強迫 xinetd 重新載入組態即可.
#ps -ef|grep xinetd
#kill -HUP xinetd_pid
4.將 /etc/xinetd.d/firebird, /opt/interbase/SYSDBA.password 的權限改為 0400, owner read-only (chmod 0400 /etc/xinet.d/firebird /opt/interbase/SYSDBA.password)
5.變更資料庫存放路徑的 owner 與權限,假設資料庫放在/var/database 下,那麼就
#chown -R firebird:firebird /var/database
#chmod -R 0770 /var/database
6.再將必要用到 Firebird 的使用者加入 firebird 群組中.
7.變更管理者密碼.
其他相關的安全性議題可以參考:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=art_fb_security


測試連接
========
執行 /opt/interbase/bin/isql 以後
在 console 輸入
>connect 'localhost:/opt/interbase/examples/employee.gdb';
如果不能連接,會出現錯誤訊息.


Firebird 1.5 RC5
================
在這一個版本裡面,安全性議題改進了不少,configuration file 更名為 firebird.conf
裡面也提供了 RemoteBindAddress 這個選項可以指定.
預設安裝路徑也變更為 /usr/local/firebird.
所以 1.5 版應該是一個安全性較高的版本,請耐心等候正式版的推出.

.Net Data Provider
==================
除了 ODBC 之外,官方網站也提供了.Net Data Provider,顧名思義就是專門給 ADO.Net 用的.
若你是使用 .Net framework 1.1 的話,需要先行安裝 msvcr70.dll,請先用本機搜尋確定一下是否有此檔案.
如果沒有,用 google 找一下,可以找到下載點 (Microsoft 未提供)
然後再安裝,一切就會很順利.
基本上,裡面的類別都是直接由 ADO.Net 的 Connection, DataSet...等等類別繼承出來,所以熟悉 ADO.Net 的話,在使用上並沒有什麼困難.
另外裡面也提供了 HtmlHelp 的說明檔以及範例程式,各位可以自行參考之.

其他
====
ElleryQ
可以轉貼,但請註明作者及出處.
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 9 樓

發表發表於: 星期六 九月 13, 2003 6:21 pm    文章主題: 引言回覆

將日期格式 '10-Sep-200'轉成 '09/10/2003'


Dialect 1 doesn't support a date-only type; but you can do this:

dateonly = cast ( cast (
extract (month from date_col) || '/' ||
extract (day from date_col) || '/' ||
extract (year from date_col) || '00:00:00.0000' as string)
as timestamp )

heLen

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 10 樓

發表發表於: 星期一 九月 29, 2003 9:52 am    文章主題: 引言回覆

如何用指令停止FireBird運作

fbmgr -shut -user SYSDBA -password masterkey

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 11 樓

發表發表於: 星期三 十月 08, 2003 11:37 pm    文章主題: 引言回覆

Q:如何建立BOOLEAN欄位屬性?

A:InterBase 7.1 以後版本已經增加了 BOOLEAN datatype.
那之前的InterBase and Firebird 就必須要透過建立domain達成.

建立方式如下列指令
CREATE DOMAIN MY_BOOLEAN INTEGER DEFAULT 0 CHECK IN (0,1)



Q:Interbase 並沒有提供布林型態的欄位,如何解決?
A:利用 domain:
CREATE DOMAIN BOOLEAN AS CHAR(1) CHECK (VALUE IN ("T","F")) NOT NULL;

至於 data-aware control 則仍是使用 TDBCheckBox, 只不過要把
ValueChecked 及 ValueUnchecked 分別設為 'T' 及 'F' 即可。

如果你的布林欄位需要顯示在 DBGrid 中,而且你所使用的 DBGrid 能夠將
布林欄位以 CheckBox 的樣式顯示出來的話,你可以利用 Calculated field
建立真正的布林欄位供顯示之用。例如:

procedure TDmod.tbleEmpCalcFields(DataSet: TDataSet);
begin
DataSet.FieldByName('CalcSex').AsBoolean :=
DataSet.FieldByName('Sex').AsBoolean;
// 注意此處欄位 Sex 雖然實際上為 'T' 或 'F', 但使用 AsBoolean
// 一樣可以得到正確值
end;

如果這樣還嫌不夠,你希望能夠以滑鼠點選 DBGrid 上的 CheckBox 來修改
該欄位的值,你可以在計算欄位的 OnChange 事件中設定真正的資料欄位值。
而為了避免發生無限遞回的情形,你必須在指定資料欄位值的時候先關閉
AutoCalcFields,參考下面的程式碼:

procedure TDmod.tblEmpCalcSexChange(Sender: TField);
begin
Sender.DataSet.AutoCalcFields := false;
if Sender.AsBoolean then
Sender.DataSet.FieldByName('Sex').AsString := 'T'
else
Sender.DataSet.FieldByName('Sex').AsString := 'F';
Sender.DataSet.AutoCalcFields := true;
end;

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################


Ruey 在 星期六 十月 11, 2003 7:22 pm 作了第 1 次修改
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 12 樓

發表發表於: 星期五 十月 10, 2003 1:18 pm    文章主題: 引言回覆

如何傳回字串長度大於某值的紀錄

You will need to install (declare and commit) the UDF function StrLen from
the ib_udf library:
DECLARE EXTERNAL FUNCTION strlen
CSTRING(32767)
RETURNS INTEGER BY VALUE
ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';

Then, your SQL will be

select * from tablename where feld2 is not null and strlen(feld2) > 250
(Pretty sure you need the not null test to avoid sending null to the function).

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 13 樓

發表發表於: 星期六 十月 11, 2003 7:09 pm    文章主題: 引言回覆

http://www.go-mono.com/firebird.html

Firebird and Interbase Data Provider

ADO.NET Data Provider for Firebird and Interbase databases

Does not exist in Mono, but is a separate project
The Firebird Relational Database is is an independent project which uses source code based on the Interbase source code released by Borland under the Interbase Public License
Both the Firebird Relational Database and the Firebird .NET Data Provider can be downloaded from here
The Firebird .NET Data provider has been made available by Carlos Guzm嫕 翼varez (aka "Carlos G.A."), who has also made a number of contributions to the OdbcJdbc code

Bugs with Mono or the data provider should be reported in Mono's Bugzilla here. If you do not have Bugzilla user account, it is free and easy to create one here.

Current Status

Current stable version: 1.0
Current developement version: 1.5
The new data provider/driver is written in C# and provides a high-performance native implementation of the GDS32/API functions. This means that .Net developers will be able to access Firebird databases without the need of Firebird client install
In support of the new module, a new mailing list firebird-net-provider has been created. Please use this list for any questions that you may have about the provider

New features & enhancements in 1.5 version

Better fit to ADO.NET
New GDS implementation
Implicit transaction support
Array datatype support
Firebird services API support
Firebird events API support
Stored procedure calls using Sql Server style
Support for retrieve database schema information ( FbConnection.GetDbSchema )
Improved Commandbuilder implementation
Testing

Need a working mono and mcs
Need access to a Firebird Relational Database or you can download it from here
Get the Firebird .NET data provider from here as firebird-net-provider. Make sure the Firebird .NET data provider binary assembly FirebirdSql.Data.Firebird.dll is installed in the same place as the mono class libraries.
Has a ConnectionString format:
"Database=databasefile.gdb;User=user;Password=pass;Dialect=3;Server=hostname"

C# Example:
using System;
using System.Data;
using FirebirdSql.Data.Firebird;

public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Database=C:\\PROGRAM FILES\\FIREBIRD\\EXAMPLES\\EMPLOYEE.GDB;" +
"User=SYSDBA;" +
"Password=masterkey;" +
"Dialect=3;" +
"Server=localhost";

IDbConnection dbcon = new FbConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql = "SELECT * FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
object dataValue = reader.GetValue(0);
string sValue = dataValue.ToString();
Console.WriteLine("Value: " + sValue);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}

Building C# Example:
Save the example to a file, such as, TestExample.cs
Build on Linux:
mcs TestExample.cs -r System.Data.dll \
-r FirebirdSql.Data.Firebird.dll

Build on Windows via Cygwin:
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
TestExample.cs \
-lib:C:/cygwin/home/MyHome/mono/install/lib \
-r System.Data.dll -r FirebirdSql.Data.Firebird.dll

Running the Example:
mono TestExample.exe

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 14 樓

發表發表於: 星期六 十月 11, 2003 7:23 pm    文章主題: 引言回覆

Q:如何取得已經連接至 Interbase 資料庫的使用者清單?
A:使用 InterBase API 函式: isc_database_info

參考以下範例:

/*
* Name: getConnectedUsers.c
*
*
* It then uses the isc_database_info call to fetch the number
* of users connected to that database
*
* Brett Bandy, June 1998
*/

#include
#include
#include "ibase.h"

void usage()
{
printf("Syntax Error:\n");
printf("\t getConnectedUsers \n");
return;
}

int main(int argc, char **argv)
{
ISC_STATUS isc_status[20];
isc_db_handle db;
char dbname[128];
char infoBuffer[] = {isc_info_user_names};
char result_buffer[512];
char *p;
char userName[32];
int length;
char item;
int i;
int userNameSize;
int totalUsers;

/* init dbhandle */
db = 0L;

switch(argc)
{
case 1:
/* get dbname from user */
printf("Enter Database to check for connections: ");
gets(dbname);
break;
case 2:
/* dbname is passed in */
strcpy(dbname, argv[1]);
break;
default:
usage();
return;
}

printf("\nAttempting to attach to database:\n\t%s\n\n", dbname);

isc_attach_database(isc_status, strlen(dbname), dbname,
&db, 0, NULL);
if(isc_status[0] == 1 && isc_status[1])
{
isc_print_status(isc_status);
exit(1);
}

/* now fetch the number of cache buffers database is using */
isc_database_info(isc_status,
&db, /* ptr to db handle */
sizeof(infoBuffer), /* size of items buffer */
infoBuffer, /* array of items to retrieve */
sizeof(result_buffer),
result_buffer); /* results will be written */
if(isc_status[0] == 1 && isc_status[1])
{
isc_print_status(isc_status);
exit(1);
}

/* initialize totalUsers */
totalUsers = 0;

/*
* Format for this call is:
*
* 1 byte: type of info item (isc_info_user_names)
* 2 bytes: length of next item (must use isc_vax_integer
* to get correct byte order)
* x bytes: next item which consists of...
* 1 byte: length of username
* x bytes: username
*
*/

/* extract the info from result_buffer */
/* loop because there can be more that one user */
for(p = result_buffer; *p != isc_info_end;)
{

item = *p++; /* item return type */

if(item != isc_info_user_names)
{
printf("Error retrieving user names\n");
return;
}

/* this will return the length of the */
/* item in bytes (length is 2 byte) */
length = isc_vax_integer(p, 2);

/* increment pointer so points to next username */
p+=2;

/* username items are stored in pascal style
<1 byte for length> */

/* get length of username */
userNameSize = isc_vax_integer(p,1);
p+=1;

/* copy username from result_buffer to userName char array */
memcpy(userName, p, length);
userName[userNameSize] = '\0';

/* advance p to point to start of next item */
p+=userNameSize;

printf("User [%s] is connected\n", userName);
totalUsers++;
}

printf("\nTotal Connected User Count is %d\n", totalUsers);

isc_detach_database(isc_status, &db);
if(isc_status[0] == 1 && isc_status[1])
{
isc_print_status(isc_status);
exit(1);
}
}

---------- ---------------------- end -------------------------------

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
Ruey



註冊時間: 2003-03-12
文章: 1698
來自: tunglo

第 15 樓

發表發表於: 星期六 十月 11, 2003 7:23 pm    文章主題: 引言回覆

Q:Interbase 資料庫發生錯誤 'database file appears corrupt (wrong type page) -
page xxxx is of wrong type',應如何解決?
A:資料庫用久了難免發生損壞,你可以使用 Interbase 的命令列工具 gfix 來修復,
或者建立一個新的資料庫,並且把有問題的資料庫中的所有資料複製到新的資料庫。
你可以採取其中一種方式:

1.修復資料庫

1) 再執行修復動作前寄得先把要修復的資料庫做一份備份,免得愈修愈慘卻無法挽回。
2) 執行 gfix -v -f database.gdb
3) 如果上一個步驟報告資料庫有損壞,則執行: gfix -m -i database.gdb
4) 重複步驟 2 看看損壞是否修復好了。

2.挽救資料

1) 建立一個新的資料庫,此資料庫的 metadata 要和損壞的資料庫相同:

A) 執行 gbak -m 以備份 metadata。可以將它回存以建立一個新的資料庫。
B) 執行 isql -x -a 以讀取 metadata 並儲存成為一個 script 檔案。
執行 isql -i scriptfile 將會建立一個新的資料庫。

2) 複製資料至新的資料庫:

A) 可以利用 Delphi 的 datapump 工具把所有的資料表複製到新的資料庫中。
B) 也可以使用 isql 來執行資料表對資料表的複製。

以上資料來源為 Interbase Corporation.

_________________
#############################
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!

學會VFP使用者社區的搜尋,Code才會更有趣~
#############################
回頂端
檢視會員個人資料 發送私人訊息
從之前的文章開始顯示:   
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區 所有的時間均為 台北時間 (GMT + 8 小時)
前往頁面 1, 2  下一頁
1頁(共2頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票
無法 在這個版面附加檔案
無法 在這個版面下載檔案


Powered by phpBB © 2001, 2005 phpBB Group
正體中文語系由 phpbb-tw 維護製作