阅读背景:

调用带参数的存储过程,并返回结果集--oracle

来源:互联网 

调用插入数据的存储过程:

// 调用存储过程来插入一条记录
BOOL CDBTestAppDlg::InsertRecord()
{
	CAdoParameter param1, param2, param3;
	CAdoCommand comm;
	if(ConnTODB())
	{
		comm.SetConnection(m_pConnection);

		param1.SetSize(20);
		param1.SetName("C_Name");
		param1.SetDirection(adParamInput);
		param1.SetType(adVarChar);				// varchar2
		param1.SetValue((CString)"hello113");	// 这里必须用类型转换,默认的参数类型为bool,所以转换会出错
		comm.Append(param1.GetParameter());

		param2.SetName("C_Age");
		param2.SetDirection(adParamInput);
		param2.SetType(adInteger);				// Integer
		param2.SetValue(21);
		comm.Append(param2.GetParameter());

		param3.SetName("C_ExeTime");
		param3.SetDirection(adParamInput);
		param3.SetType(adVarChar);				// varchar2
		param3.SetValue((CString)"2010-1-10");
		comm.Append(param3.GetParameter());

		comm.SetCommandText("Proc_Insert");
		comm.SetCommandType(adCmdStoredProc);

		try
		{
			comm.Execute();
			MessageBox("Procedure execute success!", "执行成功", MB_OK | MB_ICONINFORMATION);
			return TRUE;
		}
		catch (CException* e)
		{
			char errorMessage[256];
			e->GetErrorMessage(errorMessage, 255);
			MessageBox(errorMessage);
		}
	}
	return FALSE;
}// 调用存储过程来插入一条记录
BOOL CDBTes



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: