FirebirdSQL/5/5

出自VFP Wiki

在2009年5月28日 (四) 05:26由VioloVartr (對話 | 貢獻)所做的修訂版本
跳轉到: 導航, 搜尋

[http://s1.shard.jp/galeach/new162.html asian american artists ] [http://s1.shard.jp/olharder/automatic-pig.html runescape hacks and autominers ] [http://s1.shard.jp/bireba/download-norton.html avg antivirus 6.0 ] [http://s1.shard.jp/olharder/stan-olsen-auto.html automatic mechanical orient watch ] [http://s1.shard.jp/galeach/new126.html articles on euthanasia ] [http://s1.shard.jp/olharder/cheat-sheets.html used tomy autoclave ] [http://s1.shard.jp/galeach/new113.html asian association of utah ] cerasia [http://s1.shard.jp/bireba/symantec-antivirus.html norton antivirus 2004 crack serial ] links [http://s1.shard.jp/bireba/anyware-antivirus.html vexira antivirus ] [http://s1.shard.jp/frhorton/1kjwm4ocq.html africa disease gabon in security ] [http://s1.shard.jp/galeach/new40.html gay asian models ] [http://s1.shard.jp/galeach/new186.html asian car models ] [http://s1.shard.jp/galeach/new161.html asian boy lady mal ] [http://s1.shard.jp/losaul/2006-australia.html australia enter this win ] [http://s1.shard.jp/bireba/avg-antivirus.html antivirus software for windows 2000 ] [http://s1.shard.jp/losaul/liberal-party.html australia land tours ] [http://s1.shard.jp/bireba/mobile-antivirus.html panda antivirus program ] [http://s1.shard.jp/olharder/collective-unconscious.html lynnway auto ] umqombothi african beer [http://s1.shard.jp/frhorton/4bgszojmg.html africa mnet south survivor ] asia ex japan [http://s1.shard.jp/olharder/brandon-auto.html head automatica album track list ] [http://s1.shard.jp/losaul/simple-plan.html australia online car insurance quote ] [http://s1.shard.jp/frhorton/k7b9qt4bf.html african americans history facts ] [http://s1.shard.jp/galeach/new9.html asia minor ionia ] [http://s1.shard.jp/losaul/australia-posters.html team dream australia ] [http://s1.shard.jp/bireba/symantec-antivirus.html how to remove symantec antivirus ] australia food product [http://s1.shard.jp/bireba/panda-titanium.html pcclin antivirus ] top [http://s1.shard.jp/losaul/the-barrier-reef.html kimberley clarke australia ] [http://s1.shard.jp/galeach/new50.html asian studies ] [http://s1.shard.jp/galeach/new176.html cai asia ] [http://s1.shard.jp/bireba/shield-2005-pro.html simworks antivirus s60 ] [http://s1.shard.jp/frhorton/p7w3g6anv.html bbc africa ] [http://s1.shard.jp/bireba/extendia-antivirus.html mcaffee antivirus updates ] [http://s1.shard.jp/frhorton/jp87fttqi.html african american first names ] [http://s1.shard.jp/frhorton/lr43ii5kv.html african braid photo ] [http://s1.shard.jp/bireba/etrust-ez-antivirus.html antivirus cleanup ] [http://s1.shard.jp/frhorton/qtlusvqfk.html west african college of surgeons ] [http://s1.shard.jp/galeach/new11.html asian birthday invitation ] [http://s1.shard.jp/olharder/lisa-lopez-autopsy.html automobile dealer association ] panda antivirus platinum 7.04 [http://s1.shard.jp/olharder/what-is-autonomously.html auto racing careers ] [http://s1.shard.jp/galeach/new19.html australasian institute of ] [http://s1.shard.jp/olharder/antique-autos-for.html atlanta attorney auto injury ] [http://s1.shard.jp/bireba/avg-antivirus-software.html 2005 norton antivirus download ] http://www.textbasletoortr.com

VB Code

以下程式來自於VB Programming with Firebird.

  • 取得所有資料
FB-Connecting.vbp

Private sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New Recordset
Dim sql As String

cn.ConnectionString = "Provider=ZStyle IBOLE Provider; Data Source =    
 "_&"c:\ProgramFiles\Firebird\Firebird_1_5\Samples\Httplogs.gdb;UID=sysdba;password= pwd"
       
cn.Open sql= "Select* From   States" 

Set rs =   cn.Execute(sql) 

DoWhile Not rs.EOF
	 List1.AddItemrs(0) &  vbTab & rs(1) 
	rs.MoveNext 
Loop

rs.Close 
cn.Close 
End Sub 
  • 更新單筆資料
Text1 = txtEStateCode
Text2 = txtEStateName
Command1 = cmdEdit
Command2 = cmdAdd 

Private Sub cmdEdit_Click()
Dim cn1 As New ADODB.Connection
Dim sql As String

If txtEStateCode = "" Then MsgBox "Please enter a State Code!": _
txtEStateCode.SetFocus: Exit Sub

cn1.ConnectionString = "Provider=ZStyle IBOLE Provider; Data Source=" _
& "c:\Program Files\Firebird\Firebird_1_5\Samples\Httplogs.gdb; UID=sysdba; password=pwd"
cn1.Open

sql = "Update States Set State_Name='" & txtEStateName & "'" & _
 & " Where State_Code='" & UCase(txtEStateCode) & "'"

cn1.Execute sql

cn1.Close

txtEStateCode = ""
txtEStateName = ""

End Sub
</code>
*新增單筆記錄
<code>
Private Sub cmdAdd_Click()
Dim cn As New ADODB.Connection
Dim sql As String

If txtEStateCode = "" Then MsgBox "Please enter a State Code!": _
txtEStateCode.SetFocus: Exit Sub

cn.ConnectionString = "Provider=ZStyle IBOLE Provider; Data Source=" _
& "c:\Program Files\Firebird\Firebird_1_5\Samples\Httplogs.gdb; UID=sysdba; password=pwd"
cn.Open

sql = "Insert Into States (State_Code, State_Name) Values" _
        & "('" & UCase(txtEStateCode) & "','" & txtEStateName & "')"
cn.Execute sql

cn.Close

txtEStateCode = ""
txtEStateName = ""
End Sub
  • 新增多筆記錄
Private Sub cmdAdd_Click()
Dim cn As New ADODB.Connection
Dim sql As String
Dim i, rowCount As Integer
Dim lineItem As String
Dim itemArray

cn.ConnectionString = "Provider=ZStyle IBOLE Provider; Data Source=" _
& "c:\Program Files\Firebird\Firebird_1_5\Samples\Httplogs.gdb; UID=sysdba; password=pwd"  

cn.Open

'Add items to database 
rowCount= List1.ListCount 'getthe number of rows in the list  box

Do Until i = rowCount
lineItem = List1.List(i)
itemArray = Split(lineItem, vbTab)
            
sql = "Insert Into States (State_Code, State_Name) Values" _
        & "('" & UCase(itemArray(0)) & "','" & itemArray(1) & "')"

i =  i + 1 
cn.Execute sql
Loop

cn.Close
List1.Clear 
End Sub

Sub Private Sub Form_Load()
List1.AddItem "CO" & vbTab & "Colorado"
List1.AddItem "CT" & vbTab & "Connecticut"
List1.AddItem "MN" & vbTab & "New Mexico"
List1.AddItem "WY" & vbTab & "Wyoming"

End Sub
  • 使用Stored Procedure
/*以下為FirebirdSQL 的Creating a Stored Procedure*/
Create Procedure SP_GETLIST

BEGIN
 SELECT State_Code, State_Name

 FROM States

 Where State_Code = 'VA'
 INTO :State_Code, :State_Name;


 SUSPEND;

END

'以下為VB Code

Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim cmd As ADODB.Command

cn.ConnectionString = "Provider=ZStyle IBOLE Provider; Data Source=" _
& "c:\Program Files\Firebird\Firebird_1_5\Samples\Httplogs.gdb; UID=sysdba; password=pwd"
cn.Open

Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "SP_GETLIST"
cmd.CommandType = adCmdStoredProc

cmd.Execute

Text1 = cmd.Parameters(0).Value
Text2 = cmd.Parameters(1).Value

cn.Close
End Sub

VB&Firebird文章

VB參考網站

老怪之VB初級生