Francesco
Francesco

Reputation: 1802

"No value for parameter" error message

I'm new to Delphi7.

When I try to use the editor's "Add all fields" feature on a TClientDataSet object a messagebox (the classic error message box) appear with the message "No value for parameter '(the name of the parameter)'".
I can't add fields using the "all fields" feature anymore.
How can I find the source of the "No value for parameter" error?

Upvotes: 5

Views: 2668

Answers (3)

Francesco
Francesco

Reputation: 1802

I managed by myself. The TClientDataSet object had a parameter with DataType and ParamType properties both set to Unknown. Setting the parameter with correct properties solved the problem, I was able to "add all fields" again. Thanks for the answers.

Upvotes: 2

Patrick Moloney
Patrick Moloney

Reputation: 642

I don't think any data is necessary to do what you want - and the first answer provided does not seem to include data, even though that is the original statement. You should be able to add all fields so long as you have a connection to a table, query, stored procedure or something similar.

Your question says there is no value for a parameter, and shows which parameter - although you don't say. But it is probably the parameter for a query or such. That query is failing because you are not providing a parameter, therefore you don't get any results. Of course this includes no fields.

Check the parameter in the error message.

Upvotes: 0

Johan
Johan

Reputation: 76724

The problem is (most likely) that the ClientDataSet is not filled with any data.
Lacking data, no fields can be listed.

Do the following:

  1. put a connection on the form. [connection1]
  2. Connect it to a database fill in login, password, database, and whatnot.
  3. Make the connection active. (only possible if all the connection parameters are filled in correctly).
  4. put a table on the form. [table1]
  5. Set it's connection property to connection1.
  6. Set the tablename property to a valid table; set active to true.
  7. Put a datasetprovider on the form. [datasetprovider1]
  8. Set the dataset to table1.
  9. Put a clientdataset on your form [cds1].
  10. Set the providername of cds1 to datasetprovider1.
  11. Set cds1.Active to true

Now you can select fields, because now the cds holds actual data.

Upvotes: 3

Related Questions