<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://mochiu.net/index.php?action=history&amp;feed=atom&amp;title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC</id>
	<title>Visual Basic 6とデータベース - ODBC - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://mochiu.net/index.php?action=history&amp;feed=atom&amp;title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC"/>
	<link rel="alternate" type="text/html" href="https://mochiu.net/index.php?title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC&amp;action=history"/>
	<updated>2026-09-05T20:22:40Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://mochiu.net/index.php?title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC&amp;diff=13250&amp;oldid=prev</id>
		<title>Wiki: /* 概要 */</title>
		<link rel="alternate" type="text/html" href="https://mochiu.net/index.php?title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC&amp;diff=13250&amp;oldid=prev"/>
		<updated>2025-01-23T05:55:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;概要&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2025年1月23日 (木) 14:55時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;1行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== 概要 ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== 概要 ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ODBCは、異なるデータベース管理システムに対して統一的なアクセス方法を提供するミドルウェアである。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;データソース名 (DSN) を介して接続設定を管理して、アプリケーションからデータベースを抽象化する。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ODBCドライバを介して、SQL Server、Oracle、Access、その他様々なデータベースに接続できる。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Visual Basic 6でのデータベースアクセス方法として、ADODBが主流であった。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ADODBはODBCを含む様々なデータソースに接続でき、Connectionオブジェクトによる接続管理、Recordsetオブジェクトによるデータ操作、CommandオブジェクトによるSQL実行という機能を提供する。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;トランザクション管理、パラメータ化クエリ、ストアドプロシージャの呼び出し等、実務で必要な機能も備えている。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;エラーハンドリングについては、&amp;lt;code&amp;gt;On Error&amp;lt;/code&amp;gt;構文と&amp;lt;code&amp;gt;Err.Description&amp;lt;/code&amp;gt;を使用して実装する。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;接続設定は、システムDSN、ファイルDSN、接続文字列で管理することができる。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;実運用では、セキュリティを考慮してファイルDSNや暗号化された接続文字列を使用することが推奨されている。&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Visual Basic 6でODBCを使用する場合、一般的にADODB (ActiveX Data Objects) を使用する。&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Visual Basic 6でODBCを使用する場合、一般的にADODB (ActiveX Data Objects) を使用する。&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ADODBは、ODBCを含む様々なデータソースに対して統一的なインターフェースを提供している。&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ADODBは、ODBCを含む様々なデータソースに対して統一的なインターフェースを提供している。&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mochiu_wiki:diff:1.41:old-13249:rev-13250:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Wiki</name></author>
	</entry>
	<entry>
		<id>https://mochiu.net/index.php?title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC&amp;diff=13249&amp;oldid=prev</id>
		<title>Wiki: ページの作成:「== 概要 == Visual Basic 6でODBCを使用する場合、一般的にADODB (ActiveX Data Objects) を使用する。&lt;br&gt; ADODBは、ODBCを含む様々なデータソースに対して統一的なインターフェースを提供している。&lt;br&gt; &lt;br&gt; 代替手段として、RDO (Remote Data Objects) や DAO (Data Access Objects) も選択できるが、ADODBが最も一般的で機能が豊富である。&lt;br&gt; &lt;br&gt;&lt;br&gt;  == SQL Server == ==== SQL Serverへの接…」</title>
		<link rel="alternate" type="text/html" href="https://mochiu.net/index.php?title=Visual_Basic_6%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9_-_ODBC&amp;diff=13249&amp;oldid=prev"/>
		<updated>2025-01-23T05:44:54Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「== 概要 == Visual Basic 6でODBCを使用する場合、一般的にADODB (ActiveX Data Objects) を使用する。&amp;lt;br&amp;gt; ADODBは、ODBCを含む様々なデータソースに対して統一的なインターフェースを提供している。&amp;lt;br&amp;gt; &amp;lt;br&amp;gt; 代替手段として、RDO (Remote Data Objects) や DAO (Data Access Objects) も選択できるが、ADODBが最も一般的で機能が豊富である。&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;  == SQL Server == ==== SQL Serverへの接…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 概要 ==&lt;br /&gt;
Visual Basic 6でODBCを使用する場合、一般的にADODB (ActiveX Data Objects) を使用する。&amp;lt;br&amp;gt;&lt;br /&gt;
ADODBは、ODBCを含む様々なデータソースに対して統一的なインターフェースを提供している。&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
代替手段として、RDO (Remote Data Objects) や DAO (Data Access Objects) も選択できるが、ADODBが最も一般的で機能が豊富である。&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SQL Server ==&lt;br /&gt;
==== SQL Serverへの接続 ====&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;#039; SQL Serverへの接続を行う&lt;br /&gt;
 Private Function ConnectDatabase() As ADODB.Connection&lt;br /&gt;
    On Error GoTo ErrorHandler&lt;br /&gt;
 &lt;br /&gt;
    Dim conn As New ADODB.Connection&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; 接続文字列の設定&lt;br /&gt;
    conn.ConnectionString = &amp;quot;Driver={SQL Server};&amp;quot; &amp;amp; _&lt;br /&gt;
                            &amp;quot;Server=&amp;lt;DBサーバ名&amp;gt;;&amp;quot; &amp;amp; _&lt;br /&gt;
                            &amp;quot;Database=&amp;lt;データベース名&amp;gt;;&amp;quot; &amp;amp; _&lt;br /&gt;
                            &amp;quot;Uid=&amp;lt;ユーザID&amp;gt;;&amp;quot; &amp;amp; _&lt;br /&gt;
                            &amp;quot;Pwd=&amp;lt;パスワード&amp;gt;;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; データベースに接続&lt;br /&gt;
    conn.Open&lt;br /&gt;
 &lt;br /&gt;
    Set ConnectDatabase = conn&lt;br /&gt;
    Exit Function&lt;br /&gt;
 &lt;br /&gt;
 ErrorHandler:&lt;br /&gt;
    MsgBox &amp;quot;データベース接続エラー:&amp;quot; &amp;amp; vbCrLf &amp;amp; Err.Description, vbCritical&lt;br /&gt;
    Set ConnectDatabase = Nothing&lt;br /&gt;
 End Function&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== レコードの取得 ====&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;#039; レコードを取得する&lt;br /&gt;
 Private Sub GetRecords()&lt;br /&gt;
    On Error GoTo ErrorHandler&lt;br /&gt;
 &lt;br /&gt;
    Dim conn As ADODB.Connection&lt;br /&gt;
    Dim rs As New ADODB.Recordset&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; データベースに接続&lt;br /&gt;
    Set conn = ConnectDatabase()&lt;br /&gt;
    If conn Is Nothing Then Exit Sub&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; SQLの実行&lt;br /&gt;
    rs.Open &amp;quot;SELECT * FROM &amp;lt;テーブル名&amp;gt; WHERE &amp;lt;条件式&amp;gt;&amp;quot;, conn, adOpenStatic, adLockReadOnly&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; 結果の処理&lt;br /&gt;
    Do While Not rs.EOF&lt;br /&gt;
       &amp;#039; ここでレコードの処理&lt;br /&gt;
       Debug.Print rs.Fields(&amp;quot;列名&amp;quot;).Value&lt;br /&gt;
       rs.MoveNext&lt;br /&gt;
    Loop&lt;br /&gt;
 &lt;br /&gt;
 CleanUp:&lt;br /&gt;
    &amp;#039; リソースの解放&lt;br /&gt;
    If Not rs Is Nothing Then&lt;br /&gt;
       If rs.State = adStateOpen Then rs.Close&lt;br /&gt;
       Set rs = Nothing&lt;br /&gt;
    End If&lt;br /&gt;
    If Not conn Is Nothing Then&lt;br /&gt;
       If conn.State = adStateOpen Then conn.Close&lt;br /&gt;
       Set conn = Nothing&lt;br /&gt;
    End If&lt;br /&gt;
    Exit Sub&lt;br /&gt;
 &lt;br /&gt;
 ErrorHandler:&lt;br /&gt;
    MsgBox &amp;quot;データ取得エラー:&amp;quot; &amp;amp; vbCrLf &amp;amp; Err.Description, vbCritical&lt;br /&gt;
    Resume CleanUp&lt;br /&gt;
 End Sub&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== レコード更新 ====&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;#039; レコードを更新する&lt;br /&gt;
 Private Sub UpdateRecord(ByVal ID As Long, ByVal NewValue As String)&lt;br /&gt;
    On Error GoTo ErrorHandler&lt;br /&gt;
 &lt;br /&gt;
    Dim conn As ADODB.Connection&lt;br /&gt;
    Dim cmd As New ADODB.Command&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; データベースに接続&lt;br /&gt;
    Set conn = ConnectDatabase()&lt;br /&gt;
    If conn Is Nothing Then Exit Sub&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; コマンドの設定&lt;br /&gt;
    With cmd&lt;br /&gt;
       Set .ActiveConnection = conn&lt;br /&gt;
           .CommandType = adCmdText&lt;br /&gt;
           .CommandText = &amp;quot;UPDATE &amp;lt;テーブル名&amp;gt; SET &amp;lt;列名&amp;gt; = ? WHERE ID = ?&amp;quot;&lt;br /&gt;
           .Parameters.Append .CreateParameter(&amp;quot;@Value&amp;quot;, adVarChar, adParamInput, 50, NewValue)&lt;br /&gt;
           .Parameters.Append .CreateParameter(&amp;quot;@ID&amp;quot;, adInteger, adParamInput, , ID)&lt;br /&gt;
           .Execute&lt;br /&gt;
    End With&lt;br /&gt;
 &lt;br /&gt;
 CleanUp:&lt;br /&gt;
    &amp;#039; リソースの解放&lt;br /&gt;
    If Not conn Is Nothing Then&lt;br /&gt;
       If conn.State = adStateOpen Then conn.Close&lt;br /&gt;
       Set conn = Nothing&lt;br /&gt;
    End If&lt;br /&gt;
    Exit Sub&lt;br /&gt;
 &lt;br /&gt;
 ErrorHandler:&lt;br /&gt;
    MsgBox &amp;quot;データ更新エラー:&amp;quot; &amp;amp; vbCrLf &amp;amp; Err.Description, vbCritical&lt;br /&gt;
    Resume CleanUp&lt;br /&gt;
 End Sub&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== レコードの追加 ====&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;#039; レコードを追加する&lt;br /&gt;
 Private Sub InsertRecord(ByVal Value1 As String, ByVal Value2 As Long)&lt;br /&gt;
    On Error GoTo ErrorHandler&lt;br /&gt;
 &lt;br /&gt;
    Dim conn As ADODB.Connection&lt;br /&gt;
    Dim cmd As New ADODB.Command&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; データベースに接続&lt;br /&gt;
    Set conn = ConnectDatabase()&lt;br /&gt;
    If conn Is Nothing Then Exit Sub&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; コマンドの設定&lt;br /&gt;
    With cmd&lt;br /&gt;
       Set .ActiveConnection = conn&lt;br /&gt;
       .CommandType = adCmdText&lt;br /&gt;
       .CommandText = &amp;quot;INSERT INTO &amp;lt;テーブル名&amp;gt; (&amp;lt;列名1&amp;gt;, &amp;lt;列名2&amp;gt;) VALUES (?, ?)&amp;quot;&lt;br /&gt;
       .Parameters.Append .CreateParameter(&amp;quot;@Value1&amp;quot;, adVarChar, adParamInput, 50, Value1)&lt;br /&gt;
       .Parameters.Append .CreateParameter(&amp;quot;@Value2&amp;quot;, adInteger, adParamInput, , Value2)&lt;br /&gt;
       .Execute&lt;br /&gt;
    End With&lt;br /&gt;
 &lt;br /&gt;
 CleanUp:&lt;br /&gt;
    &amp;#039; リソースの解放&lt;br /&gt;
    If Not conn Is Nothing Then&lt;br /&gt;
       If conn.State = adStateOpen Then conn.Close&lt;br /&gt;
       Set conn = Nothing&lt;br /&gt;
    End If&lt;br /&gt;
    Exit Sub&lt;br /&gt;
 &lt;br /&gt;
 ErrorHandler:&lt;br /&gt;
    MsgBox &amp;quot;データ追加エラー:&amp;quot; &amp;amp; vbCrLf &amp;amp; Err.Description, vbCritical&lt;br /&gt;
    Resume CleanUp&lt;br /&gt;
 End Sub&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== レコードの削除 ====&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;vb&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;#039; レコードを削除する&lt;br /&gt;
 Private Sub DeleteRecord(ByVal ID As Long)&lt;br /&gt;
    On Error GoTo ErrorHandler&lt;br /&gt;
 &lt;br /&gt;
    Dim conn As ADODB.Connection&lt;br /&gt;
    Dim cmd As New ADODB.Command&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; データベースに接続&lt;br /&gt;
    Set conn = ConnectDatabase()&lt;br /&gt;
    If conn Is Nothing Then Exit Sub&lt;br /&gt;
 &lt;br /&gt;
    &amp;#039; コマンドの設定&lt;br /&gt;
    With cmd&lt;br /&gt;
       Set .ActiveConnection = conn&lt;br /&gt;
           .CommandType = adCmdText&lt;br /&gt;
           .CommandText = &amp;quot;DELETE FROM &amp;lt;テーブル名&amp;gt; WHERE ID = ?&amp;quot;&lt;br /&gt;
           .Parameters.Append .CreateParameter(&amp;quot;@ID&amp;quot;, adInteger, adParamInput, , ID)&lt;br /&gt;
           .Execute&lt;br /&gt;
    End With&lt;br /&gt;
 &lt;br /&gt;
 CleanUp:&lt;br /&gt;
    &amp;#039; リソースの解放&lt;br /&gt;
    If Not conn Is Nothing Then&lt;br /&gt;
       If conn.State = adStateOpen Then conn.Close&lt;br /&gt;
       Set conn = Nothing&lt;br /&gt;
    End If&lt;br /&gt;
    Exit Sub&lt;br /&gt;
 &lt;br /&gt;
 ErrorHandler:&lt;br /&gt;
    MsgBox &amp;quot;データ削除エラー:&amp;quot; &amp;amp; vbCrLf &amp;amp; Err.Description, vbCritical&lt;br /&gt;
    Resume CleanUp&lt;br /&gt;
 End Sub&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki&lt;br /&gt;
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板&lt;br /&gt;
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux&lt;br /&gt;
|image=/resources/assets/MochiuLogo_Single_Blue.png&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;br /&gt;
[[カテゴリ:その他]]&lt;/div&gt;</summary>
		<author><name>Wiki</name></author>
	</entry>
</feed>