我使用vc+odbc对sql server数据库进行操作,需要调用存储过程,有人说要使用命令行command,我想问一下如何创建命令行command.希望大虾结合如下一个小例子来讲解,这样便于理解。
有一个表table ,三个字段name, sex, age.
建立存储过程======计算表中有多少个男的。
create  proc   aa   @i int output
as
select  count(*) as  i   from  table   where  sex='男'
go
在vc中
cdatabase   db;
db.Open(数据源);
请问如何继续下去。
多谢。

解决方案 »

  1.   

    //使用__CommandPtr接口获取数据  __CommandPtr pCommand;  __RecordsetPtr MySet;  pCommand.CreateInstance(__uuidof(Command));  pCommand-〉ActiveConnection=MyDb;  pCommand-〉CommandText="select  from some—table";  pCommand-〉CommandType=adCmdText;  pCommand-〉Parameters-〉Refresh();  MySet=pCommand-〉Execute(NULL,NULL,adCmdUnknown);  __variant__t TheValue = MySet-〉GetCollect("FIELD__1");  CString sValue=(char)__bstr__t(TheValue);