サンプルです。
※funcUpdate関数
BeginTransはしていましたか?
もし同じ処理を行っているのであれば、そちらの不具合の出ているソースを見せてください。
※getTableColumn関数
参照設定で
Microsoft ADO Ext. x.x for DDL and Srcurity
を指定しなければいけません。
Sub funcUpdate()
Dim adoCnn As ADODB.Connection
Dim strSQL As String
' 接続を確立する
Set adoCnn = New ADODB.Connection
adoCnn.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=pubs;", "sa", ""
'新規トランザクションを開始
adoCnn.BeginTrans
'レコードに何らかの変更を加えるSQL文を実行する
strSQL = "insert into table1 (test1,test2) values ('あ','い')"
adoCnn.Execute strSQL
If MsgBox("変更を行いますか?", vbOKCancel) = vbOK Then
'変更をすべて保存
adoCnn.CommitTrans
Else
'カレント トランザクションで行った変更内容をすべてキャンセルしてトランザクションを終了
adoCnn.RollbackTrans
End If
'開放
adoCnn.Close
Set adoCnn = Nothing
End Sub
Sub getTableColumn()
Dim adoCnn As ADODB.Connection
Dim adoRec As ADODB.Recordset
Dim adoxCat As ADOX.Catalog
Dim adoxTbl As ADOX.Table
Dim adoxClm As ADOX.Column
' 接続を確立する
Set adoCnn = New ADODB.Connection
adoCnn.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=pubs;", "sa", ""
'カタログにセット
Set adoxCat = New ADOX.Catalog
adoxCat.ActiveConnection = adoCnn
'テーブルループ
For Each adoxTbl In adoxCat.Tables
Debug.Print "******************************"
Debug.Print "テーブル[" & adoxTbl.Name & "]"
'カラムループ
For Each adoxClm In adoxTbl.Columns
Debug.Print " " & adoxClm.Name
Next adoxClm
Debug.Print "******************************"
Debug.Print
Next adoxTbl
'開放
adoCnn.Close
Set adoxCat = Nothing
Set adoCnn = Nothing
End Sub