troubleshooting Question

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

Avatar of rajesh_khater
rajesh_khater asked on
Visual Basic Classic
2 Comments2 Solutions393 ViewsLast Modified:
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
jmundsack

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros