# Re: 使用ADO如下~

Posted by AOK(帝王世纪) on October 21, 1999 at 11:26:58:

In Reply to: 请问各位同好vb如何connect to DB2 posted by david on October 21, 1999 at 00:29:43:

: 请问各位同好vb如何connect to DB2
: &如何get data to mdb....tks

::(1)首先先确定你在DB2的资料库已经有"启动",若无启动,
请先用Start命令或在控制中心先启动.
(2)设定ODBC或使用Jet引擎以准备连结.
(3)Dim adoConn As ADODB.Connection
Dim adoRS As ADODB.Recordset
Dim strSQL As String

Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Connection

adoConn.Open "DSN=[资料库名];UID=[DB2通行码];
PWD=[db2通行密码]"

(P.S.)通行码一般预设都为db2admin,以上是使用ODBC
方法连结.

strSQL = "SELECT * FROM [你的资料表名]"
adoRS.Open strSQL,adoConn,...........
.
.
adoRS.Close

Follow Ups:

- 谢谢你帝王世纪,(无内文) david 13:07:19 10/23/99 (1)
  - Re: 谢谢你帝王世纪,(无内文) AOK(帝王世纪) 20:51:32 10/28/99 (0)