Re: ADO 2.7 C# - How Do I Create a Recordset On-the-Fly?
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 6 Feb 2006 16:22:06 -0000
Chris wrote on Mon, 6 Feb 2006 06:30:11 -0800:
I'm using ADO 2.7 for compatibility with an existing component I'm using.
I'm trying to add data to a recordset that I've created on-the-fly using
C# .NET 2003 (I'm new to C#, so please bear with me...). rs.Open requires
a Source and Active Connection parameter. Since the recordset is created
and populated from code, I'm not sure how to satisfy these two parameters.
In a nutshell, here's what I'm trying to do:
rs.Fields.Append("type", ADODB.DataTypeEnum.adVarChar, 1,
ADODB.FieldAttributeEnum.adFldMayBeNull, null);
rs.Fields.Append("id",ADODB.DataTypeEnum.adVarChar ,16
,ADODB.FieldAttributeEnum.adFldMayBeNull, null);
rs.Fields.Append("time", ADODB.DataTypeEnum.adVarChar, 10,
ADODB.FieldAttributeEnum.adFldMayBeNull, null);
object[] f = new object[3];
object[] v = new object[3];
f[0] = "type";
f[1] = "id";
f[2] = "time";
v[0] = type;
v[1] = ID;
v[2] = time;
object x = new object();
object y = new object();
x = null;
y = null;
rs.Open(x, y,
ADODB.CursorTypeEnum.adOpenStatic,ADODB.LockTypeEnum.adLockOptimistic,-1);
rs.AddNew(f,v);
rs.Update(f,v);
The null assignment for Source and Active Connection generate an error
when passed to rs.Open.
My other question is what is expected for FieldValue in the
rs.Fields.Append? Null is the only value I can pass without creating an
"invalid arguement" error.
Thanks,
Chris
Gah, ignore my previous reply about the creation of fields. There is no way
to set the value at creation time - you're creating a column defintion, not
a row in the recordset. You set the values when you add a new record.
Dan
.
- References:
- Prev by Date: Re: ADO 2.7 C# - How Do I Create a Recordset On-the-Fly?
- Next by Date: Re: Datasets and datatables
- Previous by thread: Re: ADO 2.7 C# - How Do I Create a Recordset On-the-Fly?
- Next by thread: Re: Datasets and datatables
- Index(es):
Relevant Pages
|
|