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.
Visual Basic Classic

Avatar of undefined
Last Comment
Guy Hengel [angelIII / a3]

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jmundsack

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Guy Hengel [angelIII / a3]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck