The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 SafeArray

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jguenrdc Posted - 05/23/2006 : 12:41:00 PM
Origin Version: OriginPro 7.5 SR6 v7.5885(B885)
Operating System: Windows XP Pro SP2

I would like to call an ADO method that takes 2 SafeArrays as parameters. Where can I find information about working with SafeArrays in Origin C? The ADO function in question is:

AddNew Method
Creates a new record for an updatable Recordset object.

Syntax
recordset.AddNew FieldList, Values
Parameters
recordset
A Recordset object.
FieldList
Optional. A single name, or an array of names or ordinal positions of the fields in the new record.
Values
Optional. A single value, or an array of values for the fields in the new record. If Fieldlist is an array, Values must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array.

I have successfully used it with a single value for each paramter:
ocrs.AddNew(1,ScoutHead.FDeployID);

I would like to use the array version so I can set several fields before the record is added to satisfy the restraints defined for my database.

Jay
2   L A T E S T    R E P L I E S    (Newest First)
jguenrdc Posted - 05/24/2006 : 12:03:03 AM
ML,

Thank you for the code sample, that was enough to help me figure it out.

Jay
ML Posted - 05/23/2006 : 3:53:21 PM
Hi jguenrdc,

Here is a simple example which shows how to create a safearray of variants and put some strings into it:


#include <variant.h>
#include <VariantTypes.h>


void test_safearray()
{
StringArray vstrValues = {"First string", "Second string", "Third string", "Fourth string"};
int nSize = vstrValues.GetSize();

// The safearray:
_VARIANT varSafeArray;
if ( !varSafeArray.CreateAsArray(VT_VARIANT, nSize) )
{
out_str("Failed to create safe array!");
return;
}

for (int ii = 0; ii < nSize; ii++)
{
_VARIANT var;
string str = vstrValues[ii];
var = str;

varSafeArray.SetOneVariantInArray(var, ii);
}

return;
}



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000