Disconnceted Recordset Question

Disconnceted Recordset Question

Post by Darin Lampso » Fri, 18 Apr 2003 01:34:14



Hi,

I am creating a custom disconnected recordset.  I am having a problem adding
new records to it.  Here is the code:

Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset

    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.Fields.Append "Model", adVarChar, 15
    rst.Fields.Append "Tag", adVariant
    rst.CursorType = adOpenDynamic
    rst.Open
    rst.AddNew
    rst.Fields(0) = "Test1"
    rst.Fields(1) = "Test2"
    rst.AddNew
    rst.Fields(0) = "Test3"
    rst.Fields(1) = "Test4"

It is only putting one record in the second one.  What am I doing wrong?

Thanks

 
 
 

Disconnceted Recordset Question

Post by Val Mazu » Fri, 18 Apr 2003 01:57:30


Hi Darin,

What do you mean "It is only putting one record in the second one"? Do you
see only first record in a recordset? If yes, then try to call Update method
of ADO recordset after you assign values

     rst.Fields(0) = "Test1"
     rst.Fields(1) = "Test2"
     rst.AddNew
     rst.Fields(0) = "Test3"
     rst.Fields(1) = "Test4"
     rst.Update

About adVariant. Why do you want to use Variant. Do not you know specific
type of data? It is always better  to use explicit type

--
Val Mazur
Microsoft MVP


Quote:> Hi,

> I am creating a custom disconnected recordset.  I am having a problem
adding
> new records to it.  Here is the code:

> Dim rst As ADODB.Recordset
>     Set rst = New ADODB.Recordset

>     rst.CursorLocation = adUseClient
>     rst.LockType = adLockBatchOptimistic
>     rst.Fields.Append "Model", adVarChar, 15
>     rst.Fields.Append "Tag", adVariant
>     rst.CursorType = adOpenDynamic
>     rst.Open
>     rst.AddNew
>     rst.Fields(0) = "Test1"
>     rst.Fields(1) = "Test2"
>     rst.AddNew
>     rst.Fields(0) = "Test3"
>     rst.Fields(1) = "Test4"

> It is only putting one record in the second one.  What am I doing wrong?

> Thanks


 
 
 

Disconnceted Recordset Question

Post by Darin Lampso » Fri, 18 Apr 2003 03:47:46


Thanks for the reply.  I figured out the problem and i do not use advariant
just accidently set it to it.


> Hi Darin,

> What do you mean "It is only putting one record in the second one"? Do you
> see only first record in a recordset? If yes, then try to call Update
method
> of ADO recordset after you assign values

>      rst.Fields(0) = "Test1"
>      rst.Fields(1) = "Test2"
>      rst.AddNew
>      rst.Fields(0) = "Test3"
>      rst.Fields(1) = "Test4"
>      rst.Update

> About adVariant. Why do you want to use Variant. Do not you know specific
> type of data? It is always better  to use explicit type

> --
> Val Mazur
> Microsoft MVP



> > Hi,

> > I am creating a custom disconnected recordset.  I am having a problem
> adding
> > new records to it.  Here is the code:

> > Dim rst As ADODB.Recordset
> >     Set rst = New ADODB.Recordset

> >     rst.CursorLocation = adUseClient
> >     rst.LockType = adLockBatchOptimistic
> >     rst.Fields.Append "Model", adVarChar, 15
> >     rst.Fields.Append "Tag", adVariant
> >     rst.CursorType = adOpenDynamic
> >     rst.Open
> >     rst.AddNew
> >     rst.Fields(0) = "Test1"
> >     rst.Fields(1) = "Test2"
> >     rst.AddNew
> >     rst.Fields(0) = "Test3"
> >     rst.Fields(1) = "Test4"

> > It is only putting one record in the second one.  What am I doing wrong?

> > Thanks