Click here to Skip to main content
16,011,170 members
Home / Discussions / Database
   

Database

 
AnswerRe: sp_OASetProperty limitations? Pin
Jeremy Falcon6-Sep-02 9:33
professionalJeremy Falcon6-Sep-02 9:33 
AnswerRe: sp_OASetProperty limitations? Pin
Nick Parker11-Sep-02 8:40
protectorNick Parker11-Sep-02 8:40 
GeneralRe: sp_OASetProperty limitations? Pin
Jeremy Falcon12-Sep-02 5:56
professionalJeremy Falcon12-Sep-02 5:56 
GeneralInserting values into sql table with C# help Pin
halbichmi6-Sep-02 6:13
halbichmi6-Sep-02 6:13 
GeneralImport diagram to SQL-server 2000 Pin
Rulle6-Sep-02 1:47
Rulle6-Sep-02 1:47 
GeneralRe: Import diagram to SQL-server 2000 Pin
notadood6-Sep-02 2:56
notadood6-Sep-02 2:56 
GeneralRe: Import diagram to SQL-server 2000 Pin
Rulle6-Sep-02 6:57
Rulle6-Sep-02 6:57 
GeneralAutomation Error Pin
bugbuster5-Sep-02 11:35
bugbuster5-Sep-02 11:35 
Hi everyone,

I'm having trouble with an Access query.
My program does one connection to the db and several queries, but only the first one is going through, the second one throws Error '-2147417851 (8001015)' which is an automation error.

I'v searched for the cause and it says it's because the server is throwing an exception.

I read in Microsoft's support site and found out that I need to do late binding, but I believe that's what I'm doing.

The code is this:

<br />
int CDBAccess::cargaConfig(char *pszComponente, CConfig *poConfig) {<br />
<br />
	_RecordsetPtr         rs;<br />
	HRESULT               hr;<br />
	_variant_t            conn;<br />
	char                  szQuery[256];<br />
	char                  szTemp[30];<br />
	FieldPtr              campo;<br />
	<br />
	try {<br />
		hr = rs.CreateInstance("ADODB.Recordset");<br />
		if(FAILED(hr)) {<br />
			m_nError = 506;//error al crear rs<br />
			return m_nError;<br />
		}<br />
		conn = (IDispatch*) m_Conec;<br />
	}<br />
	catch(_com_error & err) {<br />
		MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK);<br />
		return -1;<br />
	}<br />
	//se hace el query<br />
	sprintf(szQuery, <br />
			"select * from configuracion where componente = '%s'", pszComponente);<br />
	_bstr_t qry(szQuery);<br />
	FILE *fd;<br />
	fd = fopen("C:\\usr\\sia\\query.txt","w");<br />
	fprintf(fd,"%s",(char *)qry);<br />
	fclose(fd);<br />
	//MessageBox(NULL,(char *)qry, "cargaConfig",0);<br />
	try {<br />
		hr = rs->Open(qry, conn, adOpenStatic, adLockOptimistic, adCmdText);<br />
		if(FAILED(hr)) {<br />
			m_nError = 507;//error al abrir rs<br />
			return m_nError;<br />
		}<br />
	}<br />
	catch(_com_error & err) {<br />
		MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK);<br />
		return -1;<br />
	}<br />
<br />
	try {<br />
		//se leen los datos<br />
		campo = rs->Fields->Item["timeout"];<br />
		_bstr_t to = campo->Value;<br />
		sprintf(szTemp, "%s", (char *)to);<br />
		poConfig->iTimeout = atoi(szTemp);<br />
<br />
		campo = rs->Fields->Item["canal_comunicacion"];<br />
		_bstr_t can = campo->Value;<br />
		sprintf(poConfig->szCanalComm, "%s", (char *)can);<br />
<br />
		campo = rs->Fields->Item["id_canal"];<br />
		_bstr_t idcan = campo->Value;<br />
		sprintf(poConfig->szIdCanal, "%s", (char *)idcan);<br />
<br />
		campo = rs->Fields->Item["objeto"];<br />
		_bstr_t obj = campo->Value;<br />
		sprintf(poConfig->szObjeto, "%s", (char *)obj);<br />
<br />
		campo = rs->Fields->Item["prioridad"];<br />
		_bstr_t pri = campo->Value;<br />
		sprintf(poConfig->szPriori, "%s", (char *)pri);<br />
<br />
		hr = rs->Close();<br />
		if(FAILED(hr)) {<br />
			m_nError = 508;//error al cerrar rs<br />
			return m_nError;<br />
		}<br />
		//rs = NULL;<br />
	}<br />
	catch(_com_error & err) {<br />
		MessageBox(NULL,(LPCTSTR)err.Description(),"CargaConfig",0);<br />
		return -1;<br />
	}<br />
	return 0;<br />
}<br />


Can anyone tell me what might be wrong??

Greetings from México
GeneralRe: Automation Error Pin
notadood6-Sep-02 2:53
notadood6-Sep-02 2:53 
GeneralIdentity Seed/Increment Customize Pin
Robby5-Sep-02 5:25
Robby5-Sep-02 5:25 
GeneralRe: Identity Seed/Increment Customize Pin
Jon Hulatt6-Sep-02 3:55
Jon Hulatt6-Sep-02 3:55 
GeneralLEFT OUTER JOIN leaves rows Pin
Knappen4-Sep-02 10:18
Knappen4-Sep-02 10:18 
Generala sql query question Pin
freeworldbird4-Sep-02 7:54
freeworldbird4-Sep-02 7:54 
GeneralRe: a sql query question Pin
Mazdak4-Sep-02 7:59
Mazdak4-Sep-02 7:59 
GeneralRe: a sql query question Pin
freeworldbird4-Sep-02 8:07
freeworldbird4-Sep-02 8:07 
GeneralRe: a sql query question Pin
Mazdak4-Sep-02 23:24
Mazdak4-Sep-02 23:24 
GeneralRe: a sql query question Pin
Nick Parker4-Sep-02 9:31
protectorNick Parker4-Sep-02 9:31 
GeneralRe: a sql query question Pin
freeworldbird4-Sep-02 16:35
freeworldbird4-Sep-02 16:35 
GeneralRe: a sql query question Pin
freeworldbird5-Sep-02 16:08
freeworldbird5-Sep-02 16:08 
GeneralDatetime in SQL server<>ADO Pin
Rulle3-Sep-02 23:01
Rulle3-Sep-02 23:01 
GeneralRe: Datetime in SQL server<>ADO Pin
Jon Hulatt4-Sep-02 5:46
Jon Hulatt4-Sep-02 5:46 
GeneralRe: Datetime in SQL server<>ADO Pin
Rulle4-Sep-02 20:54
Rulle4-Sep-02 20:54 
Questionplz tell how to get rid of database error? Pin
drmzunlimited3-Sep-02 11:22
drmzunlimited3-Sep-02 11:22 
AnswerRe: plz tell how to get rid of database error? Pin
notadood4-Sep-02 4:14
notadood4-Sep-02 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.