add to recordset 
Author Message
 add to recordset

Hi there,

I have a problem with adding data to a recordset. Please have a look at my
code and tell me what I am doing wrong. I always get the message that this
procedure (rs.add) is not supported by the provider:

Option Explicit
Dim DB As ADOXCE.Catalog
Set DB = CreateObject("ADOXCE.Catalog.3.1")
DB.Create "Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0; data
source=\TestDaten.sdf"
Set rs = CreateObject("ADOCE.Recordset.3.1")
.
.
.
 rs.Open "select * from TestData", DB, adOpenKeyset, adLockPessimistic
.
.
.
private sub cmdLos_click()
Dim auswahl
 auswahl = txtID.Text
 If auswahl > rs.RecordCount Then
  rs.MoveFirst
  rs.AddNew
  rs.Fields(0) = auswahl
  rs.Fields(1) = txtVor.Text
  rs.Fields(2) = txtNach.Text
  rs.Update
  Grid.Refresh
End If
end sub

Thanks!!

Pascal



Thu, 03 Feb 2005 03:25:31 GMT  
 add to recordset
On Sat, 17 Aug 2002 21:25:31 +0200, "Pascal Schmidt-Volkmar"

Quote:

>Hi there,

>I have a problem with adding data to a recordset. Please have a look at my
[deleted]
> rs.Open "select * from TestData", DB, adOpenKeyset, adLockPessimistic

Have you tried the open statement with all the record field names
specified - "select field0, field1, field2 " etc., and not "select *"?

I'm sure I had something like this problem, and it was fixed by
putting the actual field names in the select statement.

Giles

--



Thu, 03 Feb 2005 05:41:37 GMT  
 add to recordset
Hello

try

rs.Open "TestData", DB, adOpenKeyset,
adLockPessimistic, adCmdTableDirect

only a Base Table Cursor can add rows.
A query is not updatable.

Sincerely

Christoph Eisenmann
Bangkok,Thailand

Quote:
>-----Original Message-----
>Hi there,

>I have a problem with adding data to a recordset. Please
have a look at my
>code and tell me what I am doing wrong. I always get the
message that this
>procedure (rs.add) is not supported by the provider:

>Option Explicit
>Dim DB As ADOXCE.Catalog
>Set DB = CreateObject("ADOXCE.Catalog.3.1")
>DB.Create "Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0; data
>source=\TestDaten.sdf"
>Set rs = CreateObject("ADOCE.Recordset.3.1")
>..
>..
>..
> rs.Open "select * from TestData", DB, adOpenKeyset,
adLockPessimistic
>..
>..
>..
>private sub cmdLos_click()
>Dim auswahl
> auswahl = txtID.Text
> If auswahl > rs.RecordCount Then
>  rs.MoveFirst
>  rs.AddNew
>  rs.Fields(0) = auswahl
>  rs.Fields(1) = txtVor.Text
>  rs.Fields(2) = txtNach.Text
>  rs.Update
>  Grid.Refresh
>End If
>end sub

>Thanks!!

>Pascal

>.



Thu, 03 Feb 2005 12:53:10 GMT  
 add to recordset
Hi Giles,

yes, I have tried so but the same result.

Pascal



Thu, 03 Feb 2005 15:26:45 GMT  
 add to recordset
Hi Christoph,

what do you mean by "adCmdTableDirect". Is that the name of my gridcontrol??

Thanks,

Pascal



Thu, 03 Feb 2005 15:26:24 GMT  
 add to recordset


Quote:
> Hi Christoph,

> what do you mean by "adCmdTableDirect". Is that the name of my

gridcontrol??

adXxxxxXxxxx-type thingies are constants. In this case it is one of the open
modes for an ADO table.
In order to find info on this, either look at the ADOCE On-line help under
ADOCE constants, or find a book about the usage of ADO.

And Christoph:
It is OK to update from selects. This works for me (for now):
        rs.Open "Select * from MyTable", objConn, adOpenStatic,
adLockOptimistic, adCmdText

Maybe it is the open and lock modes that does the difference?

Keld Laursen



Fri, 04 Feb 2005 14:48:31 GMT  
 add to recordset
Just to clear this up as I had a lot of problems until I found out :

You can update from selects if you are using the device internal database
provider (CDB files or the object store) but you cannot do this if you are
using SQL Server CE (SDF files).
In the case you are using SQL Server CE you can only update records if you
open the table directly (with adCmdTableDirect)

VERY annoying shortcoming of SQL Server CE.

        Niels


Quote:



> > Hi Christoph,

> > what do you mean by "adCmdTableDirect". Is that the name of my
> gridcontrol??

> adXxxxxXxxxx-type thingies are constants. In this case it is one of the
open
> modes for an ADO table.
> In order to find info on this, either look at the ADOCE On-line help under
> ADOCE constants, or find a book about the usage of ADO.

> And Christoph:
> It is OK to update from selects. This works for me (for now):
>         rs.Open "Select * from MyTable", objConn, adOpenStatic,
> adLockOptimistic, adCmdText

> Maybe it is the open and lock modes that does the difference?

> Keld Laursen



Mon, 21 Feb 2005 18:33:58 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Adding to recordset where value is null only

2. DataRepeater adding/updating Recordset

3. Adding to recordset

4. Can't add to recordset?!?

5. Add to Recordset

6. Adding a Recordset to an Array

7. 1. Adding to RecordSets 2. Schema Printing

8. Does anyone know how to add a recordset to a collection?

9. How can I add a recordset to a collection?

10. Can we Add Recordset in another Recordset

11. Adding data to table through Recordsets

12. add recordsets?

 

 
Powered by phpBB® Forum Software