Excel下面的vba如何连接db2数据库
rt
[解决办法]
Dim cnn
Dim rst
Dim strCon
strCon = "DRIVER={IBM DB2 ODBC DRIVER};DSN== <数据源名> ;UID= <用户> ;PWD= <密码> ;DBALIAS= <数据库> ; "
Set cnn = CreateObject( "ADODB.Connection ")
cnn.CursorLocation = 3
cnn.Open strCon
rst = CreateObject( "ADODB.Recordset ")
Set rst = cnn.Execute( "Select * From Area ")