Click here to Skip to main content
15,897,371 members
Home / Discussions / COM
   

COM

 
QuestionHow to programatically move a windowless control on VB form? Pin
khtong20-Aug-01 6:39
khtong20-Aug-01 6:39 
GeneralIHTMLWindow2::open creating ‘No page to display’ with IE 5.0 but not IE5.5 Pin
16-Aug-01 10:49
suss16-Aug-01 10:49 
GeneralRe: IHTMLWindow2::open creating ‘No page to display’ with IE 5.0 but not IE5.5 Pin
Not Active17-Aug-01 3:41
mentorNot Active17-Aug-01 3:41 
GeneralRe: IHTMLWindow2::open creating ‘No page to display’ with IE 5.0 but not IE5.5 Pin
mwolf17-Aug-01 4:27
mwolf17-Aug-01 4:27 
Generalcalls from atl into a DLL and VC++ weirdness Pin
16-Aug-01 3:24
suss16-Aug-01 3:24 
GeneralCOM and ATL Dialogs Pin
Mark Lenz15-Aug-01 10:33
Mark Lenz15-Aug-01 10:33 
GeneralRe: COM and ATL Dialogs Pin
Aaron Schaefer20-Aug-01 5:37
Aaron Schaefer20-Aug-01 5:37 
GeneralSeveral questions about multi dimensional SafeArray , "or" safearray challenge??? <smile> Pin
grossmay15-Aug-01 2:36
grossmay15-Aug-01 2:36 
First time posting....let's begin

I have spent the last 2 days searching the net for examples\explaination for SAFEARRAY as a mean of transferring data. This is the problem:

Client: MFC
Server: ATL COM EXE

I would like the client to give the server an SQL command, and the server to execute it.

ExecuteSQL ([in] BSTR bsSQL,........)

Very straight forward for commands such as:
"Delete from tblMyTable <where clause="">,,,,"
"Insert into tblMyTable VALUES (,,,,,)" ->you get what i mean.

However, i want the server to be able to execute commands such as
"Select * from tblMyTable". This is where a second parameter comes into the function

ExecuteSQL ([in]BSTR bsSQL, [out] VARIANT * Var,..)

I have read and re-read about safearrays, but the samples i c are good for cases where i know the size of the data i have.

Let's ASSUME (i only know this at run time) that I have a recordset of 5 columns (Fields) and 6 rows (any numbers would do as long as it is greater than 2!!!).

Can someone pls explain to me how I construct the safearray??? (PLEASE). I tried a certain method, and it seemed to work to the point where i get back to the client and on attemtping to get elements receive an "invalid index".

What i thought of doing is:

1) Declare an array of NumRows SAFEARRAYBOUND(s)
2) Each arraybound has NumFields elements (so in my case i get a 6x5 array)
3) Call SafeArrayCreate with VT_VARIANT, NumRows and the array of
safearraybounds.
4) I set the variant's type to be VT_VARIANT | VT_ARRAY

5) I declare a long Dimension[2] array to help me place the values I read
from the recordset into the 6x5 Variant array

6) I use two "for" loops to iterate through the rowsets and their fields

for (RowIndex (0);RowIndex<rowcount &&="" !rs.iseof()="" ;rowindex++)
{
="" for="" (fieldindex(0);fieldindex="" <="" fieldcount;="" fieldindex++)
="" {
="" ccomvariant="" var;
="" var="rs.Field(FieldIndex);

" dimension[1]="FieldIndex;
" dimension[0]="RowIndex;"

="" safearrayputelement(psafearr-="">parray, lDimension,&Var);
}
rs.MoveNext();
}

7) This copies all the data into the array.
8) I return to the client, get the safearray from the VARIANT, get the dims
param (yes, it is 6 <smile>) and lower(0)\upper (4) bound.

9) I declare again Dimension[2] in the client, and attempt to read the
first element (0,0) from the safearray using SafeArrayGetElement,
and......"invalid index"

10) * What am i doing wrong??
* I am using an IUnknown for the interface and define oleautomation in
the idl), will IDispatch make any difference (tried,but maybe forgot
something)
QuestionHow to use IHTMLEditHost in combination with CHtmlView Pin
Juergen Woelke15-Aug-01 1:46
Juergen Woelke15-Aug-01 1:46 
GeneralHelp with ITypeInfo Pin
Aaron Schaefer13-Aug-01 11:21
Aaron Schaefer13-Aug-01 11:21 
GeneralRe: Help with ITypeInfo Pin
Aaron Schaefer13-Aug-01 11:40
Aaron Schaefer13-Aug-01 11:40 
GeneralWM_CREATE, CWindow and HWND Pin
13-Aug-01 7:26
suss13-Aug-01 7:26 
GeneralRe: WM_CREATE, CWindow and HWND Pin
16-Aug-01 5:52
suss16-Aug-01 5:52 
GeneralShell Extentions / EXPLORER Extentions Pin
12-Aug-01 19:54
suss12-Aug-01 19:54 
GeneralVARIANT data type?! Pin
11-Aug-01 21:28
suss11-Aug-01 21:28 
GeneralRe: VARIANT data type?! Pin
Rashid Thadha12-Aug-01 23:08
Rashid Thadha12-Aug-01 23:08 
GeneralRe: VARIANT data type?! Pin
20-Aug-01 1:06
suss20-Aug-01 1:06 
GeneralHELP!!! Advise() failes when called remotely Pin
10-Aug-01 5:45
suss10-Aug-01 5:45 
GeneralRe: HELP!!! Advise() failes when called remotely Pin
Mike Player10-Aug-01 6:14
Mike Player10-Aug-01 6:14 
GeneralRe: HELP!!! Advise() failes when called remotely Pin
Rashid Thadha10-Aug-01 6:34
Rashid Thadha10-Aug-01 6:34 
GeneralConverting types Pin
8-Aug-01 20:11
suss8-Aug-01 20:11 
GeneralEvents in ASP Pin
Member 169778-Aug-01 19:47
Member 169778-Aug-01 19:47 
GeneralPerformance: Smart pointers vs CComPtr, IDispatch vs IUnknown Pin
Joe Hastings8-Aug-01 11:43
Joe Hastings8-Aug-01 11:43 
GeneralCOM Pin
8-Aug-01 0:14
suss8-Aug-01 0:14 
GeneralCalling the 2nd + method Pin
Brad Bruce7-Aug-01 8:39
Brad Bruce7-Aug-01 8:39 

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.