469,576 Members | 1,716 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,576 developers. It's quick & easy.

Old ADO problem

Hello,

i've created an old-ADO-recordset in C# via the following
code:

ADODB.RecordsetClass arTest;

arTest = new ADODB.RecordsetClass();

arTest.Fields.Append("Field1",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);

arTest.Fields.Append("Field2",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);

arTest.Open(null, null,
ADODB.CursorTypeEnum.adOpenForwardOnly,
ADODB.LockTypeEnum.adLockReadOnly,-1);

So far, so good, seems to work. Now i want to fill it with
data:
arTest.AddNew("Field1", 1);

And what i got is this:
Unhandled Exception:
System.Runtime.InteropServices.COMException (0x800A0BB9):
Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another.

Any ideas, how i can handle this?

Thanks in advance,
Daniel


Nov 15 '05 #1
2 5636

Hi Daniel,

I should have caught this in my previous post. You need to change your call
to the Open method a little further. Try:

using System.Reflection;
using ADODB;
...........
arTest.Open(Missing.Value, Missing.Value, CursorTypeEnum.adOpenStatic,
LockTypeEnum.adLockOptimistic,-1);
Full sample code for a console app follows:

using System;
using System.Reflection;
using ADODB;

namespace ConsoleApplication3
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ADODB.RecordsetClass arTest;

try
{
arTest = new ADODB.RecordsetClass();

arTest.Fields.Append("Field1",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);

arTest.Fields.Append("Field2",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);

arTest.Open(Missing.Value, Missing.Value,
ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,-1);

arTest.AddNew("Field1", 10);

System.Console.WriteLine("Field added. Value of first field
is {0}", arTest.Fields[0].Value.ToString());
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
}
finally
{
System.Console.ReadLine();
}
}
}
}
--
Rob Windsor
G6 Consulting
Toronto, Canada

"Daniel" <da****@luetke-wiesmann.de> wrote in message
news:0b****************************@phx.gbl...
Somebody send me a hint, that the recordset is opened as
read-only. I've changed it to:

arTest.Open(null, null,
ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,-1);

But the error still occures.
-----Original Message-----
Hello,

i've created an old-ADO-recordset in C# via the following
code:

ADODB.RecordsetClass arTest;

arTest = new ADODB.RecordsetClass();

arTest.Fields.Append("Field1",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null) ;

arTest.Fields.Append("Field2",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null) ;

arTest.Open(null, null,
ADODB.CursorTypeEnum.adOpenForwardOnly,
ADODB.LockTypeEnum.adLockReadOnly,-1);

So far, so good, seems to work. Now i want to fill it

with
data:
arTest.AddNew("Field1", 1);

And what i got is this:
Unhandled Exception:
System.Runtime.InteropServices.COMException (0x800A0BB9):
Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another.

Any ideas, how i can handle this?

Thanks in advance,
Daniel


.

Nov 15 '05 #2
Well, this works. Many thanks!

Greetings,
Daniel
-----Original Message-----

Hi Daniel,

I should have caught this in my previous post. You need to change your callto the Open method a little further. Try:

using System.Reflection;
using ADODB;
...........
arTest.Open(Missing.Value, Missing.Value, CursorTypeEnum.adOpenStatic,LockTypeEnum.adLockOptimistic,-1);
Full sample code for a console app follows:

using System;
using System.Reflection;
using ADODB;

namespace ConsoleApplication3
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ADODB.RecordsetClass arTest;

try
{
arTest = new ADODB.RecordsetClass();

arTest.Fields.Append("Field1",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);
arTest.Fields.Append("Field2",
ADODB.DataTypeEnum.adInteger, -
1,ADODB.FieldAttributeEnum.adFldUnspecified,null);
arTest.Open(Missing.Value, Missing.Value,
ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,- 1);
arTest.AddNew("Field1", 10);

System.Console.WriteLine("Field added. Value of first fieldis {0}", arTest.Fields[0].Value.ToString());
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
}
finally
{
System.Console.ReadLine();
}
}
}
}
--
Rob Windsor
G6 Consulting
Toronto, Canada

"Daniel" <da****@luetke-wiesmann.de> wrote in message
news:0b****************************@phx.gbl...
Somebody send me a hint, that the recordset is opened as
read-only. I've changed it to:

arTest.Open(null, null,
ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic,-1);

But the error still occures.
>-----Original Message-----
>Hello,
>
>i've created an old-ADO-recordset in C# via the following >code:
>
>ADODB.RecordsetClass arTest;
>
>arTest = new ADODB.RecordsetClass();
>
>arTest.Fields.Append("Field1",
>ADODB.DataTypeEnum.adInteger, -
>1,ADODB.FieldAttributeEnum.adFldUnspecified,null) ;
>
>arTest.Fields.Append("Field2",
>ADODB.DataTypeEnum.adInteger, -
>1,ADODB.FieldAttributeEnum.adFldUnspecified,null) ;
>
>arTest.Open(null, null,
>ADODB.CursorTypeEnum.adOpenForwardOnly,
>ADODB.LockTypeEnum.adLockReadOnly,-1);
>
>So far, so good, seems to work. Now i want to fill it

with
>data:
>arTest.AddNew("Field1", 1);
>
>And what i got is this:
>Unhandled Exception:
>System.Runtime.InteropServices.COMException (0x800A0BB9): >Arguments are of the wrong type, are out of acceptable
>range, or are in conflict with one another.
>
>Any ideas, how i can handle this?
>
>Thanks in advance,
>Daniel
>
>
>
>
>.
>

.

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Kostatus | last post: by
9 posts views Thread by Sudesh Sawant | last post: by
117 posts views Thread by Peter Olcott | last post: by
reply views Thread by James Griffiths | last post: by
18 posts views Thread by Ian Stanley | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.