<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>テキスト貼り付け用</title>
<link>https://ameblo.jp/alwenm/</link>
<atom:link href="https://rssblog.ameba.jp/alwenm/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>ブログの説明を入力します。</description>
<language>ja</language>
<item>
<title>tes</title>
<description>
<![CDATA[ <p>Sub DB_Read()<br>&nbsp; &nbsp; Dim adoCON &nbsp; &nbsp; &nbsp;As New ADODB.Connection<br>&nbsp; &nbsp; Dim adoRS &nbsp; &nbsp; &nbsp; As New ADODB.Recordset<br>&nbsp; &nbsp; Dim strSQL &nbsp; &nbsp; &nbsp;As String<br>&nbsp; &nbsp; Dim odbdDB &nbsp; &nbsp; &nbsp;As Variant<br>&nbsp; &nbsp; Dim wSheetName &nbsp;As Variant<br>&nbsp; &nbsp; Dim i &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; As Integer<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'カレントディレクトリのデータベースパスを取得<br>&nbsp; &nbsp; odbdDB = ActiveWorkbook.Path &amp; "\sample.accdb"<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'データベースに接続する<br>&nbsp; &nbsp; adoCON.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" &amp; _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Data Source = " &amp; odbdDB &amp; ";" &amp; _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Jet OLEDB:Database Password=" &amp; "a"<br>&nbsp; &nbsp; adoCON.Open<br><br><br>&nbsp; &nbsp; 'トランザクション開始<br>&nbsp; &nbsp; adoCON.BeginTrans<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'カーソルをクライアント側に設定<br>&nbsp; &nbsp; adoRS.CursorLocation = adUseClient<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'DB接続用SQL<br>&nbsp; &nbsp; strSQL = "SELECT T_item.* FROM T_item ORDER BY T_item.ID;"<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'レコードセットを開く<br>&nbsp; &nbsp; adoRS.Open strSQL, adoCON, adOpenDynamic<br><br>&nbsp; &nbsp; 'アクティブなシート名を取得<br>&nbsp; &nbsp; wSheetName = ActiveSheet.Name<br>&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; 'スタート行をセット<br>&nbsp; &nbsp; i = 3<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'テーブルの読み込み<br>&nbsp; &nbsp; Do Until adoRS.EOF &nbsp;'レコードセットが終了するまで処理を繰り返す<br>&nbsp; &nbsp; &nbsp; &nbsp; With Worksheets(wSheetName)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Cells(i, 1).Value = adoRS!ID<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Cells(i, 2).Value = adoRS!商品名<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Cells(i, 3).Value = adoRS!品番<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Cells(i, 4).Value = adoRS!単価<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Cells(i, 5).Value = adoRS!入数<br>&nbsp; &nbsp; &nbsp; &nbsp; End With<br>&nbsp; &nbsp; &nbsp; &nbsp; i = i + 1 &nbsp; &nbsp; &nbsp; '行をカウントアップする<br>&nbsp; &nbsp; &nbsp; &nbsp; adoRS.MoveNext &nbsp;'次のレコードに移動する<br>&nbsp; &nbsp; Loop<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'トランザクション終了<br>&nbsp; &nbsp; adoCON.CommitTrans<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; 'クローズ処理<br>&nbsp; &nbsp; adoRS.Close<br>&nbsp; &nbsp; Set adoRS = Nothing<br>&nbsp; &nbsp; adoCON.Close<br>&nbsp; &nbsp; Set adoCON = Nothing<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>End Sub<br><br><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/alwenm/entry-12302380063.html</link>
<pubDate>Thu, 17 Aug 2017 21:20:36 +0900</pubDate>
</item>
</channel>
</rss>
