1 / 36

いまさら聞けない VB2008 ADO.NET 超入門

いまさら聞けない VB2008 ADO.NET 超入門. 2008.05.31 初音 玲. 自己紹介. index. ADO.NET の基本的な構造. .NET データプロバイダ. DataAdapter. Parameter. プログラミング. Command. DataReader. DataSet. Connection. Transaction. プログラミング. データベース. Windows コントロール ASP.NET コントロール. DataSet クラス. メモリ上の仮想データベース DataTables コレクション

rosa
Download Presentation

いまさら聞けない VB2008 ADO.NET 超入門

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. いまさら聞けないVB2008 ADO.NET超入門 2008.05.31 初音 玲

  2. 自己紹介

  3. index

  4. ADO.NETの基本的な構造 .NETデータプロバイダ DataAdapter Parameter プログラミング Command DataReader DataSet Connection Transaction プログラミング データベース Windowsコントロール ASP.NETコントロール

  5. DataSetクラス • メモリ上の仮想データベース • DataTablesコレクション • DataTableクラス • DataRowsコレクション • DataColumnsコレクション • Constraintsコレクション • DataRelationsコレクション • RDBMSのリレーション定義に相当 • 親子関係を定義 行 列 主キー,外部キー制約

  6. .NETデータプロバイダ

  7. index

  8. Connectionオブジェクト

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

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

  11. ADO.NETからの切断 • Closeメソッドの実行 • Connectionオブジェクトの破棄 本当?

  12. index

  13. Commandオブジェクト

  14. SELECT文設定タイミング Connection 接続 タイミングは?

  15. DataReaderオブジェクト

  16. DataReaderを使う上での注意点 Using _cn As New SqlConnection(CnString) _cn.Open() Using _cmd As New SqlCommand(SqlString, _cn) Dim rd As SqlDataReader = Nothing rd = _cmd.ExecuteReader Do While rd.Read Me.ResultList.Items.Add(rd.Item("fname").ToString) Loop End Using Using _cmd As New SqlCommand(SqlString, _cn) Dim rd As SqlDataReader = Nothing rd = _cmd.ExecuteReader Do While rd.Read Me. ResultList.Items.Add(rd.Item("fname").ToString) Loop End Using _cn.Close() End Using 間違いは どこ?

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

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

  19. Parameterオブジェクト

  20. ストアドプロシージャでデータ取得 Using _cmd As New SqlCommand("byroyalty", _cn) Dim rd As SqlDataReader = Nothing _cmd.CommandType = CommandType.StoredProcedure _cmd.Parameters.Add(New SqlParameter("percentage", 40)) Try Me.ListBox1.Items.Clear() rd = _cmd.ExecuteReader Do While rd.Read Me.ResultList.Items.Add(rd.Item("au_id").ToString) Loop Catch ex As Exception MessageBox.Show(ex.Message, ・・・・) Finally If Not rd Is Nothing Then rd.Close() End If End Try End Using ALTER PROCEDURE [dbo].[byroyalty] @percentage int AS select au_id from titleauthor where titleauthor.royaltyper = @percentage

  21. index

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

  23. データソースとDataSetクラスの対応付け アプリ データソース Command DataAdapter Dataset

  24. DataAdapterオブジェクト Open タイミングは?

  25. 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

  26. CommandBuilderオブジェクト

  27. DataSetの利用時の注意点

  28. DataSetの利用時の注意点

  29. (おまけ)LINQ to SQL

  30. index

  31. 権限

  32. SQL Serverにおけるユーザ管理 SQLServer認証 SQL Server データベース データベース 旧版との互換性のため? ログイン ユーザー 認証 権限 権限 http://msdn.microsoft.com/ja-jp/library/aa905171.aspx Windows Windows認証 SQL Server こちらが推奨? Winユーザー ログイン ユーザー 認証 権限 権限 Security Policy ローカル認証だと4万人くらいが限界なのでAD認証も考慮

  33. Oracleにおけるユーザ管理 Oracle認証 Oracle インスタンス インスタンス ユーザー 認証 権限 Security Policy Windows Windows認証 Oracle ユーザー ユーザー 認証 権限 Security Policy Security Policy ローカル認証だと4万人くらいが限界なのでAD認証も考慮

  34. Windowsアプリにおけるお勧め認証構造 Winアプリ XML WEBサービス DB ID/パス渡し DB認証 Windows認証

  35. WEBアプリにおけるお勧め認証構造 ブラウザ WEBアプリ XML WEBサービス DB ID/パス渡し DB認証

  36. ありがとうございました

More Related