ADODBでデータベースに接続する(Windows限定)

Dim connection As Object
Dim recordset As Object
Dim command As Object
connection = CreateObject("ADODB.Connection")
recordset = CreateObject("ADODB.Recordset")
command = CreateObject("ADODB.Command")

'SQLServerに接続してみる
connection.Open "Provider=SQLOLEDB;Data Source=DB_SERVER\SQLEXPRESS;Initial Catalog=DB_NAME;User ID=sa;Password=123456;"

command.ActiveConnection = connection
command.CommandTimeout = 0
command.CommandText = "SELECT * FROM TABLE_NAME;"
recordset = command.Execute

If recordset.RecordCount > 0 Then
    If recordset.Eof = false Then
       recordset.MoveFirst
     MsgBox(recordset.Fields.Item("field1").Value)
       'MsgBox(recordset.Fields.Item("field1").Name) ←これは使えない
 End If
End if