_ConnectionPtr pConn(__uuidof(Connection)); |
_ConnectionPtr m_pConnection; hr = m_pConnection.CreateInstance("ADODB.Connection"); |
属性/方法 | 描述 |
---|---|
->Open ( _bstr_t ConnectionString, _bstr_t UserID, _bstr_t Password, long Options ) | 连接数据库 |
->ConnectionString | 连接字符串 |
->Close() | 关闭连接 |
.Release() | 释放句柄 |
ConnectionTimeOut | 连接超时设置, 单位:秒 |
State |
连接的状态 0 : 关闭状态 1 : 打开状态 |
->Execute ( _bstr_t CommandText, VARIANT * RecordsAffected, long Options ) | 执行语句, 返回记录指针 |
Open ( _bstr_t ConnectionString, _bstr_t UserID, _bstr_t Password, long Options ) |
Open("Provider=SQLOLEDB.1;Initial Catalog=pubs;Trusted_Connection=yes","","",adConnectUnspecified); |
参数 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConnectionString | 连接字符串, 若为 "", 则使用 ConnectionString 属性的值 | ||||||||||||||||
UserID | 用户名 | ||||||||||||||||
Password | 密码 | ||||||||||||||||
Options | 指定对数据库的更新许可权
|
_RecordsetPtr Execute( _bstr_t CommandText, VARIANT * RecordsAffected, long Options ) |
参数 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|
CommandText | SQL 语句 | ||||||||
RecordsAffected | 返回受影响行数的指针 | ||||||||
Options | 指示语句内容
|