Hi everyone.

I'm having trouble with a second query to an Access database.
The error is #-2147417851 which is an automation error.´
I've been looking for documentation on this error and found out it's about an exception thrown by the server (a COM).

In Microsoft's support page they mention the solution which is late binding, but apparently that's what I'm doing.

The code is this:
Code:
int CDBAccess::cargaConfig(char *pszComponente, CConfig *poConfig) {

	_RecordsetPtr         rs;
	HRESULT               hr;
	_variant_t            conn;
	char                  szQuery[256];
	char                  szTemp[30];
	FieldPtr              campo;
	CAdo            *ado = NULL;
	
	try {
		hr = rs.CreateInstance("ADODB.Recordset");
		if(FAILED(hr)) {
			m_nError = 506;//error al crear rs
			return m_nError;
		}
		conn = (IDispatch*) m_Conec;
	}
	catch(_com_error & err) {
		MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK);
		return -1;
	}
	//se hace el query
	sprintf(szQuery, 
			"select * from configuracion where componente = '%s'", pszComponente);
	_bstr_t qry(szQuery);
	FILE *fd;
	fd = fopen("C:\\usr\\sia\\query.txt","w");
	fprintf(fd,"%s",(char *)qry);
	fclose(fd);
	//MessageBox(NULL,(char *)qry, "cargaConfig",0);
	try {
		hr = rs->Open(qry, conn, adOpenStatic, adLockOptimistic, adCmdText);
		if(FAILED(hr)) {
			m_nError = 507;//error al abrir rs
			return m_nError;
		}
	}
	catch(_com_error & err) {
		MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK);
		return -1;
	}

	try {
		//se leen los datos
		campo = rs->Fields->Item["timeout"];
		_bstr_t to = campo->Value;
		sprintf(szTemp, "%s", (char *)to);
		poConfig->iTimeout = atoi(szTemp);

		campo = rs->Fields->Item["canal_comunicacion"];
		_bstr_t can = campo->Value;
		sprintf(poConfig->szCanalComm, "%s", (char *)can);

		campo = rs->Fields->Item["id_canal"];
		_bstr_t idcan = campo->Value;
		sprintf(poConfig->szIdCanal, "%s", (char *)idcan);

		campo = rs->Fields->Item["objeto"];
		_bstr_t obj = campo->Value;
		sprintf(poConfig->szObjeto, "%s", (char *)obj);

		campo = rs->Fields->Item["prioridad"];
		_bstr_t pri = campo->Value;
		sprintf(poConfig->szPriori, "%s", (char *)pri);

		hr = rs->Close();
		if(FAILED(hr)) {
			m_nError = 508;//error al cerrar rs
			return m_nError;
		}
		//rs = NULL;
	}
	catch(_com_error & err) {
		MessageBox(NULL,(LPCTSTR)err.Description(),"CargaConfig",0);
		return -1;
	}
	return 0;
}
I am using VC++ 6.0, and W2K Pro edition.

Thanks in advance.