快捷搜索:  xxx  as  推理研究所  幼幼  侦探研究所

恒运娱乐网页注册:VB6.0使用ADO对象连接数据库



1. 定义连接工具

Global DBconnect As New ADODB.Connection

2. 履行连接语句

If DBconnect.State = adStateOpen And Not IsEmpty(adStateOpen) Then DBconnect.Close

l连接ODBC

DBconnec恒运娱乐网页注册t.ConnectionString = "dsn=DataAliasName;uid=UserID;pwd=Passwd;"

l直接连接Access为

Dbconnect.Provider = "Microsoft.jet.OLEDB.4.0"// Access 97为3.51

DBconnect.ConnectionString = "FilePath\FileName.mdb"

l连接Oracle

DBconnect.Provider = "MSADORA"

DBconnect.Connectio恒运娱乐网页注册nString = "user/mypass@servicename

l连接SQL Server

DBconnect.Provider = "SQLOLEDB.1"

DBconnect.ConnectionString = "DATABASE= ;SERVER= ;UID= ;PWD= ;"

或者可以应用 DBconnect.Open "SERVER" , "USERID" , "PAS恒运娱乐网页注册SWORD"

DBConnect.Open

3. 取查询结果集

Global RS As Ne恒运娱乐网页注册w ADODB.Recordset

Global PS As New ADODB.Recordset

If RS.State = adStateOpen And Not IsEmpty(adStateOpen)恒运娱乐网页注册 Then RS.Close

RS.Open SQLStr, DBconnect, adOpenKeyset

4. 履行SQL语句

DBconn.Execute SQLStr

5. 关闭数据库

DBconnect.Close

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: