ADOX创建Access用户和组
// BeginGroupCpp.cpp
// compile with: /EHsc
#import "msadox.dll" no_namespace
#include "iostream"
using namespace std;
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
int main() {
if (FAILED(::CoInitialize(NULL)) )
return -1;
HRESULT hr = S_OK;
// Define and initialize ADOX object pointers. These are in ADODB namespace.
_CatalogPtr m_pCatalog = NULL;
_UserPtr m_pUserNew = NULL;
_UserPtr m_pUser = NULL;
_GroupPtr m_pGroup = NULL;
// Define String Variables.
_bstr_t strCnn("Provider=Microsoft.Jet.OLEDB.4.0;User ID=myUsername;Data Source=C:\mydatabase.mdb;Jet OLEDB:Password=myPassword;Jet OLEDB:System Database=system.mdw;");
try {
TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
m_pCatalog->PutActiveConnection(strCnn);
// Create and append new group with a string.
m_pCatalog->Groups->Append("Accounting");
// Create and append new user with an object.
TESTHR(hr = m_pUserNew.CreateInstance(__uuidof(User)));
m_pUserNew->PutName("Pat Smith");
m_pUserNew->ChangePassword("", "Password1");
m_pCatalog->Users->Append(_variant_t((IDispatch *)m_pUserNew), "");
// Make the user Pat Smith a member of the Accounting group by creating and adding the
// appropriate Group object to the user's Groups collection. The same is accomplished if a User
// object representing Pat Smith is created and appended to the Accounting group Users collection
m_pUserNew-
相关文档:
今天谈两个ASP运行时可能出现的与IIS有关的错误
-------------------------------------------------------------------
错误类型一:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 不能更新。数据库或对象为只读。
错误类型二:
Microsoft OLE DB Provider ......
sqlserver:update Table_A set Table_A.col1 = (select Table_B.col1 from Table_B where Table_A.col2 = Table_B.col2)
Access: UPDATE Table_ A, Table_B SET Table_ A.字段2 = Table_ B.字段2
WHERE Table_ A.编号=Table_ A.编号;
自己记下,提醒自己 ......
最近系统运行中发现Access 2003 版本中对待 Null 和 ‘’ (空字符)奇怪问题,重现步骤:
1、创建表tabTest ;
2、使用设计视图添加两个字段 ID ,col1
名称
类型
长度
说明
ID
Number
主键,自增
Col1
char
1
无
3、使用sql 添加如下数据
-- col1 字段设置为 null
INS ......
public static DataTable GetSchemaTable(string connectionString) //获取Access所有的表名;
{
using (OleDbConnection connection = new
&n ......
熟悉SQL SERVER 2000的数据库管理员都知道,其DTS可以进行数据的导入导出,其实,我们也可以使用Transact-SQL语句进行导入导出操作。在 Transact-SQL语句中,我们主要使用OpenDataSource函数、OPENROWSET 函数,关于函数的详细说明,请参考SQL联机帮助。利用下述方法,可以十分容易地实现SQL SERV ......