※参照設定を使用しない場合は不要

②以下サンプル(接続文字列はODBC接続)
③使用例
- Option Compare Database
- Option Explicit
- Private Const CON_STRING As String = "DSN=TEST_ODBC;Uid=USER1;Pwd=userpass1;Database=TEST_DB"
- Private m_cn As New ADODB.Connection
- ' コネクションオープン用
- Public Sub OpenConnection()
- m_cn = New ADODB.Connection
- m_cn.ConnectionString = CON_STRING
- m_cn.Open
- End Sub
- ' コネクションクローズ用
- Public Sub CloseConnection()
- m_cn.Close
- End Sub
- ' コネクション取得用
- Public Function GetConnection() As ADODB.Connection
- Set GetConnection = m_cn
- End Function
- Option Compare Database
- Private Sub test()
- Dim rst As New ADODB.Recordset
- Call OpenConnection
- rst.ActiveConnection = M_Connection.GetConnection
- rst.Open "select * from TEST_TBL1;"
- rst.Close
- Set rst = Nothing
- Call CloseConnection
- End Sub
0 件のコメント:
コメントを投稿