What are the “Missing SQL property” here?

When trying to execute the code:

function TDBClass.addNome(nome: String): String;
var
  rsnome: TADOQuery;
begin
  rsnome := TADOQuery.Create(nil);
  rsnome.Connection := connection;
  rsnome.Open();
  rsnome.SQL.Clear;
  rsnome.SQL.Text:='UPDATE enroll SET nome = "test" where id ="1"';
  rsnome.Parameters.ParamByName('nome').Value:= nome;
  rsnome.ExecSQL;
  rsnome.post();
  rsnome.Close();
  rsnome.Free();
end;

I'm receiving the error message "Missing SQL property". Where did I go wrong? Thanks in advance!

Answers


I don't think you want to use Open at all, and you are using parameters incorrectly. i.e. the SQL doesn't have any :PARAM placeholders in it. I think it should be something like: rsnome.SQL.Text:='UPDATE enroll SET nome = :NOME where id = :ID';

See this example: AdoQuery Error using parameters


You're calling rsnome.Open before setting the SQL by rsnome.SQL.Text := ....


Need Your Help

“Invalid authorization specification” error on UCanAccess connect

java ms-access netbeans ucanaccess persistence-unit

I am having a problem with the UCanAccess driver namely that when I attempt to connect to a database using the following code

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.