Link to home
Create AccountLog in
Avatar of rajesh_khater
rajesh_khater

asked on

AddNew not working on an ADO recordset having WHERE clause in its query

Hi,

I have opened a recordset, passing a SQL statement to the rs.Open method.

The SQL statement is having a WHERE clause to filter specific records. The query is something like:
 SELECT * FROM MyTable WHERE OrderNo = 1

The records are coming properly.

But when the user enters values in a form to add a record to the underlying table, my code does:

rs.AddNew

At that time, I get the error:

Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

I have opened the Recordset with these parameters:

rs.Open sqlQuery, dbConn, adOpenStatic

I have also tried changing the above to adOpenDynamic.

But it is not working.

Please tell whether its possible to do an AddNew on a recordset based on a query with a WHERE clause.

I have checked that the table included in the query has a Primary Key defined and this key is being fetched by the SQL statement.

If AddNew is not possible, please suggest an alternative approach, which will also keep this recordset updated. Because I am displaying the values from the recordset into a FlexGrid.
ASKER CERTIFIED SOLUTION
Avatar of jmundsack
jmundsack
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account