|
要看什么数据库,一般通过ADO可连接,下面是SQLServer的例子:- Dim Conn
- Dim Rst
- Dim str_Link_DBSource
- str_Link_DBSource="Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=TEST"
- Set Conn=CreateObject("ADODB.Connection")
- Conn.Open str_Link_DBSource
- Set Rst=CreateObject("ADODB.Recordset")
- Rst.Open "select * from Orders",Conn,2,2
- Rst.MoveFirst
- Do While Rst.Eof<>true
- Print Rst.Fields(0) & " " & Rst.Fields(1) & " " & Rst.Fields(2)
- Rst.MoveNext
- Loop
- Rst.Close
- Conn.Close
- Set Rst=Nothing
- Set Conn=Nothing
复制代码 |
|