'Syntax error: Missing operand after '10' operator
I have a code like this:
DataRow[] foundRows = dsFoxhillComp.Tables["RotaComp"].Select(findAssignee);
int test = foundRows.Length;
find Assignee is the result of this:
string combobox2 = comboBox2.SelectedItem.ToString();
string assignee = combobox2.Substring(0, 5).ToString();
string assignedShift = "";
string assignedDate = (item.SubItems[1].Text.ToString());
if (dateTimePicker2.Value >= Convert.ToDateTime("09:00:00") && dateTimePicker2.Value < Convert.ToDateTime("12:59:59"))
{
assignedShift = "1";
}
else if (dateTimePicker2.Value >= Convert.ToDateTime("13:00:00") && dateTimePicker2.Value < Convert.ToDateTime("16:59:59"))
{
assignedShift = "2";
}
else if (dateTimePicker2.Value >= Convert.ToDateTime("17:00:00") && dateTimePicker2.Value < Convert.ToDateTime("19:59:59"))
{
assignedShift = "3";
}
string findAssignee = assignee + assignedShift + assignedDate;
This is, I hope, going to either find or not find something in my database, so I can then use that as a comparison for an If statement, I have seen people use similar things on different sites. But when I run it, I get the following error:
System.Data.ExpressionNode Parse()Syntax error: Missing operand after '10' operator.
I have no idea what could be causing this. Google searching had said something about apostrophes being in the dataset, but I've checked, and there shouldn't be. Any advice would be greatly appreciated.
Thanks.
Solution 1:[1]
So, the comment from Matthias R. Jessen was correct and worked, so Matthias, thank you very much. So that there's a logged answer, what worked was:
.Select($"[ColumnName] LIKE '%{findAssignee}%'");
As opposed to my original code, which I have now replaced.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SDev95 |
