chillibear.com

Current provider does not support returning multiple recordsets from a single execution" ADO exception and solution

Took me a while before I realised what I was doing wrong here, but it’s one of those silly things where it’s obvious once you know. I was trying to add a record to my database using the following code that I had based on code I was using to read records.

ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('INSERT INTO locations (x, y) VALUES (1, 2)');
ADOQuery1.Open;

Every time up would fire the same exception error, well the answer is quite simple - you can’t open that query because it doesn’t return a record.

That’s why the nice ADO people provide the ExecSQL method. So the above code should read:

ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('INSERT INTO locations (x, y) VALUES (1, 2)');
ADOQuery1.ExecSQL;

Exception error all gone!

Written on 23 Dec 2008 and categorised in Delphi, tagged as ADO and SQL

Home, Post archive

site copyright Eric Freeman

Valid XHTML 1.0 Strict