/
Miku  + Oracle = Visual Basic ? Miku  + Oracle = Visual Basic ?

Miku + Oracle = Visual Basic ? - PowerPoint Presentation

contera
contera . @contera
Follow
344 views
Uploaded On 2020-08-03

Miku + Oracle = Visual Basic ? - PPT Presentation

20080607 初音 玲 自己紹介 タイトルの意味は Visual Basic 2008 Oracle Database 11 g Release 1 20080607 初音 玲 Part2 index ADONET の基本的な構造 NET ID: 795924

net oracle visual database oracle net database visual odp studio odt cmd trn release oraclecommand windows update index connection

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "Miku + Oracle = Visual Basic ?" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Miku + Oracle = Visual Basic ?

2008.06.07

初音 玲

Slide2

自己紹介

Slide3

タイトルの意味は?

Slide4

Visual Basic 2008+Oracle Database 11g Release 12008.06.07初音 玲

Part.2

Slide5

index

Slide6

ADO.NETの基本的な構造.NETデータプロバイダ

Connection

Command

DataReader

DataAdapter

データベース

DataSet

Windows

コントロール

ASP.NET

コントロール

Transaction

Parameter

プログラミング

プログラミング

Slide7

ODP.NETの基本的な構造ODP.NET

Oracle

Connection

Oracle

Command

Oracle

DataReader

Oracle

DataAdapter

Oracle Database

DataSet

Windows

コントロール

ASP.NET

コントロール

Oracle

Transaction

OracleParameter

プログラミング

プログラミング

Slide8

Visual StudioからOracleに接続Visual Studio

ODP.NET

Oracle

Database

ODE.NET

アセンブリ

ODT

ODP.NET

ODP.NET

デプロイ

.NET

ストアド

(

アセンブリ

)

ビルド

ODP.NET:Oracle

Data Provider for .NET

ODT

:

Orace

Developer Tools for Visual Studio

ODE.NET:Oracle

Database Extensions for .NET

Slide9

ODTとVSのバージョン関連表対応DBバージョン

対応

Visual Studio

ODT 10.1.x.x

Oracle 9i

Database Release 2

Oracle Database 10g Release 1

Visual

Studio

.NET 2003

ODT 10.2.0.1

Oracle 9i

Database Release 2

Oracle Database 10g Release 1

Oracle Database 10g Release 2

Visual

Studio .NET 2003ODT 10.2.0.2Oracle8i R8.1.7.4以降Visual Studio

.NET 2003Visual Studio 2005

ODT 11.1.0.6Oracle 9i Database Release 2~Visual

Studio .NET 2003Visual Studio 2005Visual Studio 2008

~ODT 10.2:サーバーエクスプローラとは別ODT 11.1

~:サーバーエクスプローラに統合

Slide10

専用ミドルウェアは、やっぱり速い

OLE DB .NET Data Provider

OLE DB Provider for Oracle

ODP.NET

oo4o

ログオン

2.4

3.0

3.2

1.0

参照

2.0

3.5

3.5

1.0

追加

0.7

1.0

1.0

1.0

更新

0.7

1.2

1.2

1.0

10

VB2005+oo4o

の処理時間を1としたときの相対比

独自プログラムによる測定

Slide11

DataSetクラスメモリ上の仮想データベースDataTablesコレクションDataTableクラス

DataRows

コレクション

DataColumns

コレクション

Constraints

コレクション

DataRelations

コレクション

RDBMS

のリレーション定義に相当

親子関係を定義

主キー

,

外部キー制約

Slide12

ODP.NET

Slide13

index

Slide14

Connectionオブジェクト

Slide15

接続文字列の設定タイミング

Slide16

ADO.NETからのエラーの取得Exception

いいかも?

Slide17

DBサーバ

アプリケーション

ODP.NET

接続プーリング

ODP.NET

のデフォルト動作は

Pooling=True

User Id={0};Password={1};Data Source=

ホスト文字列

;

接続

切断

接続

切断

接続

切断

接続処理

疑似

疑似

疑似

疑似

疑似

Slide18

index

Slide19

Commandオブジェクト

Slide20

SELECT文設定タイミング

Connection

接続

タイミングは?

Slide21

DataReaderオブジェクト

必須なのは?

必須なのは?

Slide22

DataReaderを使う上での注意点Using _cn As New OracleConnection(CnString)

_

cn.Open

()

Using _

cmd

As New

OracleCommand

(

SqlString

, _

cn

)

Dim rd As

OracleDataReader = Nothing rd = _cmd.ExecuteReader Do While

rd.Read Me.ResultList.Items.Add(rd.Item("fname

").ToString) Loop End Using Using _cmd As New OracleCommand(

SqlString, _cn)

Dim rd As OracleDataReader = Nothing rd = _cmd.ExecuteReader

Do While rd.Read Me. ResultList.Items.Add(rd.Item("fname").ToString

) Loop End Using

_cn.Close()End Using

間違いはどこ?

Slide23

列単位でデータを実取得する

Slide24

Parameterオブジェクトなぜ違う?

Slide25

Parameterオブジェクト

Slide26

GUI操作によるDBアプリ作成 26

DEPT

EMP

マスターディテール形式の画面を作成

GUI

操作のみ

SplitContainer

詳細

DataGridView

Slide27

GUI操作による開発と生産性GUIでお手軽開発で良いか検討すべてをカバーするものではない

意図したタイミングで意図したデータを取得

業務の特性に合わせて

画面の特性に合わせて

お客様の特性に合わせて

そのためには

やはりコーディングが必要

27

Slide28

index

Slide29

SQL文の直接実行(Commandオブジェクト)

Slide30

データソースとDataSetクラスの対応付け

データソース

Command

DataAdapter

Dataset

アプリ

Slide31

DataAdapterオブジェクトOpen

タイミングは?

Slide32

CommandBuilderでSQL作成_cn.Open()Using _tr As

SqlTransaction

= _

cn.BeginTransaction

()

Using _

cmd

As New

SqlCommand

("SELECT * FROM employee ", _

cn

)

_

cmd.Transaction = _tr '###

重要### Using _da As New SqlDataAdapter(_

cmd) Using _cb As New SqlCommandBuilder(_da) _

da.UpdateCommand = _cb.GetUpdateCommand() _

da.InsertCommand = _cb.GetInsertCommand() _da.DeleteCommand

= _cb.GetDeleteCommand() Try _da.Update(Ds, "employee") _tr.Commit

() Catch ex As Exception

MessageBox.Show(ex.Message, ・・・) _tr.Rollback

() End Try End Using End Using End Using

End Using

Slide33

CommandBuilderオブジェクトThis property is not supported.

実装すらされていません

Slide34

DataSetの利用時の注意点

Slide35

DataSetの利用時の注意点

Slide36

トランザクション処理GUI操作で作成したDBアプリには致命的障害保存ボタンで保存されるのは、DEPTのみ

36

Me.Validate()

Me.DEPTBindingSource.EndEdit()

Me.DEPTTableAdapter.Update(Me.DataSet1.DEPT)

EMP

への

Update

メソッドを追加で解決?

DEPT

更新後、

EMP

更新に失敗すると

……..

トランザクション制御が必要

Slide37

暗黙的なトランザクションTableAdapterごとにConnectionが存在Connectionに対するトランザクションでは無理

37

System.Transactions

クラスを

使う

DEPTTableAdapter

オブジェクト

EMPTableAdapter

オブジェクト

Oracle

Database

OracleConnection

オブジェクト

OracleConnection

オブジェクト

OracleCommand

オブジェクト

OracleCommand

オブジェクト

MS-DTC (

マイクロソフト分散トランザクションコーディネータ

)

MS

-DTC (

マイクロソフト

分散トランザクションコーディネータ

)

Slide38

暗黙的なトランザクションTry

Me.Validate()

Using _trn As New System.Transactions.TransactionScope

Me.DEPTBindingSource.EndEdit()

Me.DEPTTableAdapter.Update(Me.DataSet1.DEPT)

'

Me.EMPBindingSource.EndEdit()

Me.EMPTableAdapter.Update(Me.DataSet1.EMP)

'

_

trn.Complete()

'

トランザクション完了

End Using

Catch ex As System.Transactions.TransactionAbortedException

MessageBox.Show(ex.Message)Catch ex As Exception

MessageBox.Show(ex.Message)

End Try38

System.Transactions

の参照設定を忘れないように

ADO.NET 2.0からはCOM+カタログ登録不要GACへの登録不要

Slide39

明示的なトランザクションConnectionが1つConnectionに対するトランザクションで可能39

Oracle

Database

OracleConnection

オブジェクト

OracleCommand

オブジェクト

OracleCommand

オブジェクト

Slide40

明示的なトランザクション_trn = cn.

BeginTransaction

()

Try

_DBCmdEMP.

Transaction

= _trn

_DBCmdDEPT.

Transaction

= _trn

_DBCmdEMP.ExecuteNonQuery()

_DBCmdDEPT.ExecuteNonQuery()

_trn.Commit()Catch ex As Exception

_trn.Rollback()End Try

40

Slide41

(おまけ)LINQ to SQL

Slide42

index

Slide43

権限

Slide44

WindowsOracleにおけるユーザ管理

Oracle

Oracle

認証

Oracle

Windows

認証

ユーザー

ローカル認証だと

4

万人くらいが限界なので

AD

認証も考慮

インスタンス

ユーザー

インスタンス

ユーザー

認証

認証

権限

権限

Security

Policy

Security

Policy

Security

Policy

Slide45

Windowsアプリにおけるお勧め認証構造

XML WEB

サービス

DB

DB

認証

Win

アプリ

ID/

パス渡し

Windows

認証

Slide46

WEBアプリにおけるお勧め認証構造

ブラウザ

XML WEB

サービス

DB

DB

認証

W

EB

アプリ

ID/

パス渡し

Slide47

まとめ接続接続プーリングデータ取得コード記述開発GUI操作開発データ更新

CommandBuilder

トランザクション

権限

Oracle

認証

Windows

認証

Slide48

QA