最近有个数据库课程设计,要利用存储过程的,我用odbc连得的数据库,想在程序里运用存储过程该怎么用啊,我建了个存储过程是关于查询的,下面是查询的代码我应该把那段代码修改下,是它可以运用创建的存储过程。
ng = 0;
CRecordset rs(&m_db);//类对象代表一个从数据源中获取的纪录集
//打开所有的用户信息记录
rs.Open(CRecordset::dynaset, "select * from kehu  where name ='"+m_chaxun+"'");
 //rs.Open(CRecordset::dynaset, "execute jiaoshichaxun '"+m_chaxun+"'");

 while (!rs.IsEOF()) 
{
int num;
CString kehunum,kehuname,phone,buytime,yaopinbianhao,yaopinname;
CDBVariant var;
//获取客户信息ID字段值

//获取姓名字段值
rs.GetFieldValue((short)0,kehunum);
//获取分数字段值
rs.GetFieldValue(1,kehuname);
            rs.GetFieldValue(2,phone);
            rs.GetFieldValue(3,buytime);
            rs.GetFieldValue(4,yaopinbianhao);
rs.GetFieldValue(5,yaopinname);
rs.GetFieldValue((short)6, var, SQL_C_SLONG);
if (var.m_dwType != DBVT_NULL)
num = var.m_iVal;
var.Clear();
//rs.GetFieldValue(6,jiage)
InsertCRInfoItem(kehunum,kehuname,phone,buytime,yaopinbianhao,yaopinname,num);
//InsertCRInfoItem(CString kehunum,CString kehuname,CString phone,CString buytime,CString yaopinbianhao,CString yaopinname,int num)
rs.MoveNext();
}
rs.Close();
}
UpdateData(false);
int nIndex = m_list.GetItemCount();
if(nIndex==0)
{
MessageBox("对不起,没有要查询的数据");
}