UԈႢ炯̃f[^ANZXvEp邽߂
Direct ORA / Direct SQL
LЃCgEc[ \
ؑbr/>̃R|[lg̖{̂́ADirectSQL.DLLłAVisual BasicȂǂ͎QƐݒĎgBg͂ăJ^łBVisual BasicgƂ̗B
TṽfBNg: \DirectSQL\Samples\Pubs
- @
- DBLibraryIuWFNg̍쐬 Dim oDBL As New DBLibrary ̂悤ɂāADBLibraryIuWFNg쐬B炷ׂĂn܂BȌ́AoDBLx[XɂׂĂ̍ƂŝŁAVisual Basicł̃IuWFNg̃ANZX邽߂ɁAWith`End WithubN̒ŋLq邱ƂɂB
With oDBL R[hc End With
- T[o[Ƃ̐ڑ Initialize\bhŏƁAT[o[Af[^x[XA|U[ApX[hw肵AOpen\bhŐڑB
' ڑ .Initialize .Server = "sqlsvr" .Database = "pubs" .User = "sa" .Password = "passwprd" .Open
- SQL̔s ^ϐsSQLSQLݒ肵ACompile\bhSQLRpCAExecute\bhŎsBSQĹATransact SQLŋLqꂽGȂ̂łĂŎs"\łBASELECTłȂANVNG[XgAhvV[W̎sȂǂ"\łB
' SQL̔s .Compile sSql .Execute
- Resultset̎擾 Transact SQLsƁASQL Server1ȏResultsetԂBƂAXg(DirectSQL\Samples\Pubs\rept.sql)̂悤ȕGSQLSQL ServertISQL/w[eBeBgĎsƁA}̂悤ɕ̏邱ƂnYB́ux܂v1ZbgЂƂResultsetȂ̂łB
DirectSQLł́AGetNextResultvpeBQƂ邲ƂɁAResultset邱Ƃł悤ɂȂĂBselecťʂȂǂFetcĥ́Â悤Ƀ[vōsƂɂȂB
Do While .GetNextResult 'Resultset͓ǂݔ If .Columns.Count <> 0 Then FetchȂǂ̏c End If Debug.Print "RowCount:"; .RowCount Loop
ISQL/wł悤ɁAuSELECT @pub_id = "%%%%%%%%"v̂悤ȕɑĂResultsetԂĂ킯A͌ʃZbgƂĎ擾Kv͂ȂBŁAColumnus.CountvpeB0̂Ƃɂ́AFetchȂǂ͂ȂŁAGetNextResults悢B
FetchɂĂResultseťʂ荞ŁARowCountvpeBɂ͏ꂽsԂB
ȂAResultsetKvȂƂAKvResultsetoɂ́ACancel\bhgĂ̂ƂResultsetj邱ƂłB
衝撃フィットボード
JColumnts.CountvpeB0ȊÔƂɂ́AJJ擾邱ƂłB
Column̓RNVɂȂĂ̂ŁAColumn("ID") ̂悤ɃJw肵AColumn(1)̂悤ɔzCNɃANZX邱ƂłB܂AJ́AColumnName(index)œ邱ƂłB
̃R[h́A1ڂFetcĥƂɃJ\ĂAJ̓e\łB
bFirst = True Do While .GetNextResult Do While .Fetch If .Columns.Count <>0 Then If bFirst Then For i = 1 To .Columns.Count Debug.Print .Columns(i).Name;","; Next i Debug.Print bFirst = False End If For i = 1 To .Columns.Count Debug.Print .Columns(i);","; List1.AddItem .Columns(i) Next i Debug.Print End If Loop Debug.Print "RowCount:"; .RowCount Loop
ۂɁAقǎXg̕GSQLsʂ}ɎB
̕GSQLɂāAƐĂBSQĹAMS SQL ServerɃCXg[Tvf[^x[Xpubsɂ11̃e[ûA6ɃANZX(DirectSQL\Samples\Pubs\pubs.xlsERDV[g)AeƃCeB(쌠)̌vẐłBŎgĂe[u\ɂĕ\(pubs.xls̃e[uV[g)ɎBł́Â悤ȂƂOɁA҂ɎxCeB̌vZĂB
- @
- ҂ɑāAЂɉđOex(titles/advance etc.)
- ҂ɉāA̔ɂ̊ŃCeBx(titles/royalty etc.)
- ҂ւ̎x́AXoŎЂɑxꂽƂB(on invoiceƂȂĂ̂͏X痂ɏoŎЂɎx̂ƂB܂A҂ւ̎x͗XƂȂ)
Ƃ낪ASQL}X^[ĂÂ悤SQLLq邱ƂłAISQL/wŎsēmF邱ƂłBƂ낪AȕGSQLVisual Basic + ̂ւ̈ʓIȃ~hEFAł͓ƂłȂ̂łBISQL/wœmF̂ɁAĂѕ̃NG[ɃoVisual BasicɌvẐ͓Ǝv낤?
Ȑl͂Ȃ낤B
DirectSQL͌�br/>̃R|[lg̖{̂́ADirectORA.DLLłADirectSQLlVisual BasicȂǂ͎QƐݒĎgBgDirectSQLlăJ^ł邪ADBLibraryNet8Ƃ�= sServer oOra.User = sUser oOra.Password = sPassword
@
サスペンションは、バイクにどのように動作するか
Dim oCur As OciCursor Set oCur = oOra.Open@
oCur.Compile = "select * from c" oCur.Execute
Dim oCol As OciColumn bFirstTime = True Do While oCur.Fetch If bFirstTime Then sValue = "" For Each oCol In oCur.Columns sValue = sValue & oCol.Name & vbTab Next lstX.AddItem sValue bFirstTime = False End If sValue = "" For Each oCol In oCur.Columns sValue = sValue & oCol.Value & vbTab Next lstX.AddItem sValue Loop
@
MsgBox CStr(oCur.RowsAffected) & "R[h܂B", vbInformation, "DirectOra"
oCur.Close Set oOra = Nothing
DirectORAłBindϐ̎g
DirectORAł́ABindϐgƂł悤ɂȂĂBTṽfBNg: \DirectORA\Samples\bind
@ DirectORÃIuWFNgfɂAOciFloatAOciIntegerAOciString̊eIuWFNgValuevpeB́AꂼꂪFloatAIntegerAString̃oChϐƂāAVisual BasicȂǂ̃c[ANZX邱ƂłB
ƂÂ悤ɊeIuWFNg쐬Ƃ悤B
Dim fval As New OciFloat Dim fval2 As New OciFloat Dim ival As New OciInteger Dim sval As New OciString
PL/SQLubNŁA:fA:f3A:sA:IA:c͂ꂼPL/SQLubNAȂ킿OracleT[o[߂oChϐłB
ドイツのトップ10 fordhändler
begin :f := 3.14; :f3 := :f * :f2; :s := 'hello, world'; :i := 123; :c := 'Edit!'; end;
PL/SQLubNRpCB
oCur.Compile txtSQLBind.Text
Visual Basicł́Â悤Bind\bhgVisual BasicŃANZXłϐƂăoChBƂAPL/SQLubŃu:fvfvalɃoChB܂Ał͕^TextBoxRg[̃ftHglłTextvpeBɃoCh邱ƂłB
oCur.Bind "f", fval fval2 = txtF2.Text oCur.Bind "f2", fval2 oCur.Bind "f3", txtF3 oCur.Bind "i", ival oCur.Bind "s", sval oCur.Bind "c", txtReturn
Execute\bhŎsABindĂ邱ƂmFłB
oCur.Execute Debug.Print fval Debug.Print ival Debug.Print sval
̃vOł낢̂́AVisual Basiĉ悤 Signed^̐lȂł̓I[o[t[Ă܂悤ȌvZAOracleɂ点Ă܂Ƃł邱ƂBƂAvẐ̓iZXł邩AȂ炩̃NG[ƋɎsׂ낤B
܂ADirectORAł́Â悤PL/SQLubNsł邩AXgA[hvV[WXgA[htxtSQLBind2.Text oCur2.Bind "empno", txtMinEmpNo oCur2.Execute
Execute\bhsɁALink\bhempnoenameAꂼeLXg{bNXtxtEmpNotxtEnameɃf[^oCfBO邱ƂłB
oCur2.Columns.Item("empno").Link = txtEmpNo oCur2.Columns.Item("ename").Link = txtEname
xAf[^oCfBOĂ܂Aʂ̃{^ȂǂFetch ĂƁA̍s̓eIɕ\B
mɕ֗łB܂łłUPDATE܂Ŏɂ悤ȋC邪ADirectORA𖼏Vvȃ~hEFAƂvz͏XĂ܂B܂AXV炢UPDATEBindϐgċLqĂ悢낤BmɏXSQLȂǂԂ͂邪A̕yȂ̂łB
�br/>Oracle: CREATE_SQL.XLS
ExcelDirectR|[lggAV[gɋLqꂽe[u`ɂāAe[uCfbNX(̃Jgݍ킹̂)쐬邱Ƃłc[łBł́AV[g=e[uƂăe[u̒`ĂB
ɁA.dateV[gɂ́Af[^͂ĂAe[u쐬ɓ邱ƂłBf[^ɂ́ASQL̊LqēIɓ悤ɂ邱ƂłB
{͂܂悭ȂƂł͂邪A|U[̗vJɔô߃XL[}̐vύXȂƂB̂悤ȂƂɁAXL[}쐬Excel̃V[gɋLqȂŁAXOɃXL[}č쐬ł̂́AɌ悢B
܂AfobOɃf[^ƂAۂɉ^pɓĂ}X^[̃f[^ꊷ肵ȂĂ͂ȂȂƂBƂɂÃc[͈З͂B
悤ɍlĂƁANxȂǂɃf[^ExcelɎ擾ēvAʂ̃obNAbve[uɈڍs邱ƂAJ^łB
TvvO:Edit.Vbp
ł́AVisual BasicDirectR|[lggāA1.œ͂}X^[f[^ɂāA~σf[^쐬AvP[VB
̃c[ł́Ai}X^[ITEMƒS҃}X^[PERSONQƂȂA̔~σe[uSALEɃf[^ljACA폜ł悤ɂȂĂBłȂǂ̋zvZ͎ōsB
ł́A͂ꂽ̔tL[ɂāÃR[hړĕ\ł悤ɂȂĂBMovePreviouśAɏqׂ悤�br/>Oracle: REPORT_ORA.XLS
[c[ł́A܂܂ExcelgĂB̔~σe[uƊe}X^[ɃANZXAグ̈ꗗV[gɎ擾ĂB
̃c[ł͂܂ĂȂAExcel̕\`ɂ͌E͂̂́AȂɂꂢɃtH[}bgĈ邱ƂłAWvȂǂ邱ƂłBɁAOtȂǂłB
ɂ悢Ƃ́ÃV[gƕʖŕۑĂA⌎ȂǂAłȂ̂ƂExcel`̃f[^ƂĒ~ς邱ƂłB
̂悤ɁA܂ÂCAEgvȂ̂łAExcel͂Ȃg肪悭Ap[c[ƂĎgƂł̂łB
0 コメント:
コメントを投稿