VC如何添加sql server用户?

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:43:56
VC如何添加sql server用户?

sql语句我已写出,VC如何执行我的sql语句?或者调用什么或用别的什么方法向sql server添加用户?

可以使用数据库类来直接执行SQL语句,就可以了。下面是在ADo中的代码参考
⑸执行SQL命令
使用Connection对象的Execute
_RecordsetPtr connection15::Execute(_bstr_t CommandText,VARIANT* RecordsAffected, long Options)
CommandText 命令文本
RecordsAffected 操作完成后所影响的行数
Options 命令文本的类型 取值和Recordset类的Open函数中的Options一样。
_variant_t aff;
theApp.m_pConn->Execute(_T("insert into name(姓名,性别,年龄)alues('zhong',false,21)"), &aff,adCmdText);
record1=m_pConn->Execute(_T("select count(*) from name"),&aff,adCmdText);
使用Command对象的Execute
_CommandPtr m_pComm;
m_pComm.CreateInstance(__uuidof(Command));
m_pComm->ActiveConnection=theApp.m_pConn;
m_pComm->CommandText=_T("insert into name(姓名,性别,年龄) values('chang',false,22)");
m_pComm->Execute(NULL,NULL,adCmdText);
strSql.Format("select distinct num from bank1 where bank='%s'",entry->name);
strSql=_T("