CDatabase db;
db.OpenEx("ODBC;DSN=testdb;user=sa;pwd=pass");CSockSet set((&db));
set.Open(...);
set.close();db.Close();
解决方案 »
- 如何过滤重复的数据,急!!
- select '1' 用法
- 关于字符串转换的问题
- 请问when case可以用到count(*)查询中吗?
- exec master..xp_cmdshell 'bcp Vegatable.dbo.V_out out d:\qq.xls -c -q -s"zyp" -u"sa" -p"asdasd"'
- 写一个存储过程表名可以是参数吗??
- [新手问题]怎样直接在程序中用代码新建或者编辑Job?
- 如何设置服务帐户的权限
- 还是没明白SQLServer的用户的概念.....
- 数据库中日期格式怎么变?
- 请问什么是ldap?
- 有关触发器的问题!!!分必给,回答好者,另加高分!!!
我一直在用你这样的语句访问sql server.
怎么不弹出对话框。
是不是你的用户名称和密码不对,
我在::GetDefaultConnect()中只有
"ODBC;DSN=testdb”;
1.return _T("ODBC")
系统提是对话框让你选择数据源等信息。
2。return _T("ODBC;DSN=mydsn")
需要用户和密码
3。return _T("ODBC;DSN=mydsn;UID=myid")
需要密码
4。return _T("ODBC;DSN=mydsn;UID=myid;PWD=mypwd")
用户提供了所有的信息。
CDatabase::OpenEx
virtual BOOL OpenEx( LPCTSTR lpszConnectString, DWORD dwOptions = 0 );
throw( CDBException, CMemoryException );Return ValueNonzero if the connection is successfully made; otherwise 0 if the user chooses Cancel when presented a dialog box asking for more connection information. In all other cases, the framework throws an exception.ParameterslpszConnectStringSpecifies an ODBC connect string. This includes the data source name as well as other optional information, such as a user ID and password. For example, "DSN=SQLServer_Source;UID=SA;PWD=abc123" is a possible connect string. Note that if you pass NULL for lpszConnectString, a Data Source dialog box will prompt the user to select a data source.dwOptionsA bitmask which specifies a combination of the following values. The default value is 0, meaning that the database will be opened as shared with write access, the ODBC Cursor Library DLL will not be loaded, and the ODBC connection dialog box will display only if there is not enough information to make the connection. CDatabase::openExclusive Not supported in this version of the class library. A data source is always opened as shared (not exclusive). Currently, an assertion fails if you specify this option.
CDatabase::openReadOnly Open the data source as read-only.
CDatabase::useCursorLib Load the ODBC Cursor Library DLL. The cursor library masks some functionality of the underlying ODBC driver, effectively preventing the use of dynasets (if the driver supports them). The only cursors supported if the cursor library is loaded are static snapshots and forward-only cursors. If you plan to create a recordset object directly from CRecordset without deriving from it, you should not load the cursor library.
*****请注意这里******
CDatabase::noOdbcDialog Do not display the ODBC connection dialog box, regardless of whether enough connection information is supplied.
CDatabase::forceOdbcDialog Always display the ODBC connection dialog box.