Windows 10 Pro_x64 + Excel2013_x86 VBA で ADODB.Command オブジェクトを少し試してみる
Windows 10 Pro_x64 + Excel2013_x86 VBA で ADODB.Command オブジェクトを少し試してみる
Command は基本ストアド用って感じではあるんだけど、まぁ「簡単なコマンドの作成と実行」ということで
参考にしたのは以下のサイト
対象テーブルはこちら
Windows 10 Pro_x64 + Excel2013_x86 VBA DataBase Access クラスを使って書き込んでみる
Dim adoCon As ADODB.Connection Dim adoRst As New ADODB.Recordset Dim adoCmd As New ADODB.Command Dim host As String Dim user As String Dim pass As String Dim conn As String ' host = "SQLSVODBC32" user = "demo" pass = "demo" ' conn = "DSN=" & host & ";UID=" & user & ";PWD=" & pass ' Set adoCon = New ADODB.Connection ' adoCon.ConnectionString = conn adoCon.CursorLocation = adUseClient Call adoCon.Open ' adoCmd.ActiveConnection = adoCon ' adoCmd.CommandText = "SELECT * FROM ZIPCODE WHERE SEQ = '00046801'" adoCmd.CommandType = adCmdText ' Set adoRst = adoCmd.Execute While Not adoRst.EOF Debug.Print Trim(adoRst.Fields("KUBUNCODE")) & vbTab & _ Trim(adoRst.Fields("POSTAL")) & vbTab & _ Trim(adoRst.Fields("CITIESKANJI")) & vbTab & _ Trim(adoRst.Fields("POADDRKANJI")) ' adoRst.MoveNext Wend ' adoCon.Close Set adoCon = Nothing Set adoCmd = Nothing