When looking at the RecordsetClass in the ADODB primary interop assembly, the
AddNew method has the following signature
ADODB::RecordsetClass::AddNew([System::Object], [System::Object])
The text suggests that both parameters are arrays of objects, but it doesn't
accept an array<Object^>^. Is there any other way of getting this to work?
Thanks
Colin 4 1242
the following works for me:
ADODB::RecordsetClass ^ test = gcnew RecordsetClass();
array<Std::String ^> ^ fields = {"fieldName"};
array<Std::String ^> ^ values = {"Value"};
test->AddNew(fields, values);
the AddNew method throws an exception because i have not opened a connection
(don't know plain ADO that well), but there is no problem with passing the
arrays.
kind regards,
Bruno.
"Colin Desmond" wrote: When looking at the RecordsetClass in the ADODB primary interop assembly, the AddNew method has the following signature
ADODB::RecordsetClass::AddNew([System::Object], [System::Object])
The text suggests that both parameters are arrays of objects, but it doesn't accept an array<Object^>^. Is there any other way of getting this to work?
Thanks
Colin
Thanks for that Bruno,
Unfortunately it doesn't work for me. Here is my code
RecordsetClass^ rs = gcnew RecordsetClass();
rs->CursorLocation = ADODB::CursorLocationEnum::adUseClient ;
rs->CursorType = ADODB::CursorTypeEnum::adOpenStatic;
rs->LockType = ADODB::LockTypeEnum::adLockBatchOptimistic;
rs->default->Append("Column 1", ADODB::DataTypeEnum::adVarChar, 60,
ADODB::FieldAttributeEnum::adFldFixed, nullptr);
rs->default->Append("Column 2", ADODB::DataTypeEnum::adVarChar, 60,
ADODB::FieldAttributeEnum::adFldFixed, nullptr);
rs->default->Append("Column 3", ADODB::DataTypeEnum::adVarChar, 60,
ADODB::FieldAttributeEnum::adFldFixed, nullptr);
rs->Open(Type::Missing, Type::Missing, ADODB::CursorTypeEnum::adOpenStatic,
ADODB::LockTypeEnum::adLockBatchOptimistic, -1);
array<String ^> ^ fields = {"Column 1"};
array<String ^> ^ values = {"Value 1"};
rs->AddNew(fields, values);
The AddNew throws the following exception
"Item cannot be found in the collection corresponding to the requested name
or ordinal."
The only difference I can see between your code and mine is you use
Std::String and I used System::String, I can't get Std::String to compile!
Any thoughts?
Colin
now that i could have a look at your code, the first thing that comes to mind
is that your record set contains 3 columns, but when you add a new row, you
only supply a value or 'Column 1'.
have you tried supplying values for all 3 fields? the exception message
seems to indicate that this is your problem.
i don't know why i used Std::String instead of System::String. I used
std::string a lot in native C++. i guess it was an sub concious typo :)
kind regards,
Bruno.
"Colin Desmond" wrote: Thanks for that Bruno,
Unfortunately it doesn't work for me. Here is my code
RecordsetClass^ rs = gcnew RecordsetClass(); rs->CursorLocation = ADODB::CursorLocationEnum::adUseClient ; rs->CursorType = ADODB::CursorTypeEnum::adOpenStatic; rs->LockType = ADODB::LockTypeEnum::adLockBatchOptimistic;
rs->default->Append("Column 1", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr); rs->default->Append("Column 2", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr); rs->default->Append("Column 3", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr);
rs->Open(Type::Missing, Type::Missing, ADODB::CursorTypeEnum::adOpenStatic, ADODB::LockTypeEnum::adLockBatchOptimistic, -1);
array<String ^> ^ fields = {"Column 1"}; array<String ^> ^ values = {"Value 1"};
rs->AddNew(fields, values);
The AddNew throws the following exception
"Item cannot be found in the collection corresponding to the requested name or ordinal."
The only difference I can see between your code and mine is you use Std::String and I used System::String, I can't get Std::String to compile!
Any thoughts?
Colin
Bruno,
I have tried
array<String ^> ^ fields = {"Column 1", "Column 2", "Column 3"};
array<String ^> ^ values = {"Value 1","Value 2","Value 3"};
then
rs->AddNew(fields, values);
but it still throws the same exception.
Colin
"Bruno van Dooren" wrote: now that i could have a look at your code, the first thing that comes to mind is that your record set contains 3 columns, but when you add a new row, you only supply a value or 'Column 1'.
have you tried supplying values for all 3 fields? the exception message seems to indicate that this is your problem.
i don't know why i used Std::String instead of System::String. I used std::string a lot in native C++. i guess it was an sub concious typo :)
kind regards, Bruno. "Colin Desmond" wrote:
Thanks for that Bruno,
Unfortunately it doesn't work for me. Here is my code
RecordsetClass^ rs = gcnew RecordsetClass(); rs->CursorLocation = ADODB::CursorLocationEnum::adUseClient ; rs->CursorType = ADODB::CursorTypeEnum::adOpenStatic; rs->LockType = ADODB::LockTypeEnum::adLockBatchOptimistic;
rs->default->Append("Column 1", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr); rs->default->Append("Column 2", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr); rs->default->Append("Column 3", ADODB::DataTypeEnum::adVarChar, 60, ADODB::FieldAttributeEnum::adFldFixed, nullptr);
rs->Open(Type::Missing, Type::Missing, ADODB::CursorTypeEnum::adOpenStatic, ADODB::LockTypeEnum::adLockBatchOptimistic, -1);
array<String ^> ^ fields = {"Column 1"}; array<String ^> ^ values = {"Value 1"};
rs->AddNew(fields, values);
The AddNew throws the following exception
"Item cannot be found in the collection corresponding to the requested name or ordinal."
The only difference I can see between your code and mine is you use Std::String and I used System::String, I can't get Std::String to compile!
Any thoughts?
Colin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: its me |
last post by:
Let's say I have a class of people...
Public Class People
Public Sex as String
Public Age as int
Public Name as string
end class
And I declare an array of this class...
|
by: James |
last post by:
Hi, I'm hoping someone can help me out.
If I declare a class, eg.
class CSomeclass
{
public:
var/func etc.....
private
varfunc etc..
|
by: Robert Mark Bram |
last post by:
Hi All!
How do you get the length of an associative array?
var my_cars= new Array()
my_cars="Mustang";
my_cars="Station Wagon";
my_cars="SUV";
alert(my_cars.length);
|
by: VK |
last post by:
Hello,
In my object I have getDirectory() method which returns 2-dimentional
array
(or an imitation of 2-dimentional array using two JavaScript objects
with auto-handled length property - please...
|
by: Tom Jastrzebski |
last post by:
Hello,
I was just testing VB.Net on Framework.Net 2.0 performance when I run into
the this problem.
This trivial code attached below executed hundreds, if not thousand times
faster in VB 6.0...
|
by: yeti349 |
last post by:
Hi, I'm using the following code to retrieve data from an xml file and
populate a javascript array. The data is then displayed in html table
form. I would like to then be able to sort by each...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: heddy |
last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int
Newsize); and the newsize is smaller then what the array was
previously, are the resources allocated to the objects that are...
|
by: JJA |
last post by:
I'm looking at some code I do not understand:
var icons = new Array();
icons = new GIcon();
icons.image = "somefilename.png";
I read this as an array of icons is being built.
An element of...
|
by: StevenChiasson |
last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller.
This is more or less, your...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |