_ConnectionPtr m_pCon;
if(FAILED(hr=m_pCon->Open(_bstrDataSource,
_bstr_t(L""),
_bstr_t(L""),
adModeUnknown)))
return hr;
谁能解释一下,open函数中4个参数的含义?为什么msdn中差不到ado调用方法?
我想调一个interbase的数据库,有用户和密码,应该在什么地方更改,是否有特别的地方?
if(FAILED(hr=m_pCon->Open(_bstrDataSource,
_bstr_t(L""),
_bstr_t(L""),
adModeUnknown)))
return hr;
谁能解释一下,open函数中4个参数的含义?为什么msdn中差不到ado调用方法?
我想调一个interbase的数据库,有用户和密码,应该在什么地方更改,是否有特别的地方?
解决方案 »
- 在vc2008中,用CreatePointFont函数为什么输出中文时会变成乱码?搜狗和五笔都是一样的。
- 请问, VC中如何判断XML中某个节点中的属性是否存在?
- 同样两个点,主动连接和被动连接后在传输速度上是否会存在差异
- 我拷贝一个sdk文件,由后缀名为.cue .bin .sfv 组成 怎么安装?
- 急!!VC++中如何使用InterBase数据库?高手请指点!
- 自定义弹出菜单问题
- 如何动态插入代码?
- 哪位大侠知道Activemovie控件的使用?
- 视频图像采集时 读入剪切板的数据拷贝不出
- 当一个线程正在处理一个消息时,还能不能接受到其他消息?
- 急问c或vc中有没有16进制转换的函数?
- 怎样将一个位图(CBitmap)对象存为文件?
第二个:用户名
第三个:密码
第四个:打开方式(同步/异步)[email protected], 来信送你一本ado的书,大部分例子都是vb的,部分是c++的,对于学习足够了。
Opens a connection to a data source.Syntax
connection.Open ConnectionString, UserID, Password, Options
Parameters
ConnectionString
Optional. A String value that contains connection information. See the ConnectionString property for details on valid settings.
UserID
Optional. A String value that contains a user name to use when establishing the connection.
Password
Optional. A String value that contains a password to use when establishing the connection.
Options
Optional. A ConnectOptionEnum value that determines whether this method should return after (synchronously) or before (asynchronously) the connection is established.
Res
Using the Open method on a Connection object establishes the physical connection to a data source. After this method successfully completes, the connection is live and you can issue commands against it and process the results.Use the optional ConnectionString argument to specify either a connection string containing a series of argument = value statements separated by semicolons, or a file or directory resource identified with a URL. The ConnectionString property automatically inherits the value used for the ConnectionString argument. Therefore, you can either set the ConnectionString property of the Connection object before opening it, or use the ConnectionString argument to set or override the current connection parameters during the Open method call.If you pass user and password information both in the ConnectionString argument and in the optional UserID and Password arguments, the UserID and Password arguments will override the values specified in ConnectionString.When you have concluded your operations over an open Connection, use the Close method to free any associated system resources. Closing an object does not remove it from memory; you can change its property settings and use the Open method to open it again later. To completely eliminate an object from memory, set the object variable to Nothing.Remote Data Service Usage When used on a client-side Connection object, the Open method doesn't actually establish a connection to the server until a Recordset is opened on the Connection object.
Note URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.
See Also
Visual Basic Example | VBScript Example | Visual C++ Example | Visual J++ ExampleOpen Method (ADO Record) | Open Method (ADO Recordset) | Open Method (ADO Stream) | OpenSchema MethodApplies To: Connection Object
讲的很详细!去看看吧!
if (FAILED(pConn.CreateInstance("ADODB.Connection")))
{
AfxMessageBox("Create Instance failed!");
return;
}_bstr_t bstrSRC(strSRC); if (FAILED(pConn->Open(bstrSRC,"","",-1)))
{
AfxMessageBox("Can not open Database!");
pConn.Release();
return;
}
if (FAILED(pConn.CreateInstance("ADODB.Connection")))
{
AfxMessageBox("Create Instance failed!");
return;
}
CString strSRC; strSRC="DRIVER=Microsoft Visual FoxPro Driver;";//这里可写你所选择的数据库驱动类型
strSRC+="SourceType=DBF;";
strSRC+="SourceDB=";
strSRC+=strFoldName;//在这里写你的数据库表存放的路径
strSRC+=";UID=SA;PWD=";
_variant_t varSRC(strSRC);
_bstr_t bstrSRC(strSRC); if (FAILED(pConn->Open(bstrSRC,"","",-1)))
{
AfxMessageBox("Can not open Database!");
pConn.Release();
return;
}