Adding a WHERE clause to select_command makes some lines uneditable

QuestionsAdding a WHERE clause to select_command makes some lines uneditable
David asked 9 years ago

Hi,

I tried to search for an answer to this but couldn't find the problem.

I have a grid which i populate with a select command on my ms sql table.

If I take the full content of the table it works fine, but if i add the WHERE clause then only the last line is selectable and if i delete this line all the lines will be deleted.

I redid the table to add a id column just to try having unique values in the first column.

The following line is the working one:

$gr->select_command = "SELECT id, ref_NO_CLIENT, ref_NO_RUBRIQUE, DESCRIPTION_FR, SEQUENCE FROM Cli_Rub INNER JOIN ATCQ_RUBRIQUES ON Cli_Rub.ref_NO_RUBRIQUE = ATCQ_RUBRIQUES.NO_RUBRIQUE";

And now the line that mess things up: ($CLE contains the NO_CLIENT)

$gr->select_command = "SELECT id, ref_NO_CLIENT, ref_NO_RUBRIQUE, DESCRIPTION_FR, SEQUENCE FROM Cli_Rub INNER JOIN ATCQ_RUBRIQUES ON Cli_Rub.ref_NO_RUBRIQUE = ATCQ_RUBRIQUES.NO_RUBRIQUE WHERE id LIKE '$CLE%'";

Any help figuring why just adding this would mess things up would be appreciated.

Thanks

3 Answers
Abu Ghufran answered 9 years ago

The first column of grid must have unique alphanumeric data (usually a PK).
This is required for proper display as well as update & delete operations of particular row.

David answered 9 years ago

The first column (id) is my PK and contains unique value in each row.

Like I said the only difference between the 2 queries is the Where clause I added because I want to edit 1 particular client instead of all clients.

If I change it to filter on the client number and hardcode a value (for test purpose) I will still have the same problem…

David answered 9 years ago

OK I found out my error. It works now.

Problem was with the column configuration for my id.

Your Answer

4 + 17 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?