hi, i have this code to fill a data adapter in c#.net:
this.freedomScooterServiceBindingSource.Filter = "CustomerID = " + comboBoxCustomer.SelectedValue;
It worked fine during running of the application, but when i exit the application, it threw error "Syntax Error, Missing operand after '=' operator" on this line of code
i checked it against some sample code, ther is no syntax error, but why is this happening
plz help

Syntax Error, Missing operand after '=' operator
Ricky Mendoza
now everything is working fine, I figured out the problem:
it's because the comboBox control I use in the new project was copy-and-pasted from the old project, probably .net wasn't smart enough to create a new combobox object, which caused the error.
I got rid of this problem by simply deleting this combobox and created new one with same name, and .net automatically created an object reference.
Sorry for my bad explanation :)
RiskSWDeveloper_WorkEmail
Hi,
Unfortunatelly I have issues with the above problem.
I came upd to a single line of code which might be related to this:
dataTable.Select(dataTable.Columns["country_id"].ColumnName + " = " + defCountry + " ");
defCountry being an Int32.
At some point(for now it seems totaly random), it throws me the same exception like the one from the begining of this thread.
Is the Select() call finally using the Filter property
Many thanks,
Adi
Sagar Joshi
hi Michael, I am now working on a new project, I still get the same problem....., plz help
in the "Data Binding Mode" of comboBoxCusName, I set "DisplayMember" to "CustomerName", the "Value Member" to "CustomerName", same column, because I only retrieve one column from the db, the query is:
SELECT DISTINCT CustomerName FROM [Freedom Scooter Service Reminder]
in the project, I code this:
this.BindingSourceCusV.Filter = "CustomerName = " + "'" + comboBoxCusName.SelectedValue.ToString() + "'";
it worked. however, again, at the end, when close/exit the application, i get an error message pointing on the line of code above:
"NullReferenceException was unhandled ----- Object reference not set to an instance of an Object"
why is this
another problem is that everytime when I select a customer name from the combobox, the listbox correctly displays services for selected customer, but the comboboxCusName itself goes wrong, the dropdown list gets messy itself, some customer names disappeared, some are duplicated. plz help
Peter Hogg
ssfftt,
You should use this
this.BindingSource.Filter = String.Format("CustomerID='{0}'",comboBoxCustomer.SelectedItem.ToString());
Again this is where the String.Format will come in handy :-)
I hope this has helped you!
-Will
Let me know if you are still having any issues with this!
-Will
waveheatin
ssfftt:
I'd start be seeing whether you are missing the single quotes in your filter string. The example for BindingSource shows this:
BindingSource1.Filter = "ContactTitle='Owner'";
So perhaps your line of code should look like this:
this.freedomScooterServiceBindingSource.Filter = "CustomerID = " + " ' " + comboBoxCustomer.SelectedValue + " ' ";
This error might also occur if comboBoxCustomer.SelectedValue is null or empty.
Michael Blome - VIsual C# Documentation Team
Ramachandran
thx for your help Michael :)
I put single quotes in my code, application runs no problem, however, error happened again when i exit the application, but different message:
Cannot perform "=" operation on System.Int32 and System.String.
btw, the selected value is set in data binding mode
freddoo
Hi Will, unfortunatelly, I gave up on this problem, modified this project so that it doesn't have this form anymore. Anyway, thx for your help