This is a migrated thread and some comments may be shown as answers.

Missing operand before '=' operator

6 Answers 1124 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 05 Feb 2009, 09:18 PM
We have a very simple report, with just couple of TextBoxes on it.

private void InitializeComponent() 
   ... 
   this.titleTextBox = new Telerik.Reporting.TextBox(); 
   this.txtBody = new Telerik.Reporting.TextBox(); 
   ... 
 
   InitializeComponent(); 
 
   this.titleTextBox.Value = "Header"
   this.txtBody.Value = "==="
 

When we set the value of a TextBox to "===", we get a very strange error:

An error has occured while processing TextBox 'txtBody': 
Syntax error: Missing operand before '=' operator
 

If we set the value to '---' it works fine.

It looks like you're using the '=' character to indicate that we should be doing a data substitution.  How do we stop this from happening?

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Feb 2009, 09:20 AM
Hi Jeff,

Indeed we're using the '=' character to indicate that we should be doing a data substitution. So in this line of thoughts, the data can be string e.g.  ="===".

Regards,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 06 Feb 2009, 04:01 PM
That doesn't really do it.
We're trying to display a remarks field from the database, into which the users could have typed pretty much anything.

This wasn't working:
this.txtBody.value = "===NOTICE==="

Per your message, I've tried this:
this.txtBody.value = String.Format("=\"{0}\"""===NOTICE==="); 

That seems to handle strings that contain equal signs, but it breaks on strings that contain double-quotes:
this.txtBody.Value = String.Format("=\"{0}\"""My name is \"Joe\""); 

We get an error: "Missing operator before Joe operand."  I've tried escaping the embedded double-quotes:
this.txtBody.Value = String.Format("=\"{0}\"""My name is \\\"Joe\\\""); 
But I get the same error.

Surely there is some way of putting arbitrary text into a report.  How?



0
Steve
Telerik team
answered on 09 Feb 2009, 05:22 PM
Hello Jeff,

The cases you describe do not apply if your data is really coming from the database, because in this case the expression for the textbox item would be =Fields.MyField and MyField would be evaluated properly.

Greetings,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 09 Feb 2009, 06:08 PM
If you phrased that as "coming from a data source", yes, I understand that.

This problem only occurs when you're constructing a report in code, rather than binding a report to a data source.
1
Steve
Telerik team
answered on 12 Feb 2009, 03:22 PM
Hello Jeff,

According to your explanations "We're trying to display a remarks field from the database", you are getting the fields from a database and they would be properly evaluated as described in my previous post.
If you want to hardcode such a string in the report constructor you can do it directly:

this.txtBody.Value = String.Format("=\"{0}\"", "My name is \"Joe\"");
i.e.
this.textBox1.Value = "My name is 'Joe'";

Let us know if we're missing the point here, but can you present us with a real-life scenario where this can actually be a problem?

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeff
Top achievements
Rank 1
answered on 12 Feb 2009, 04:27 PM
Just because the data originates in a database does not mean that it's being handed to your report generator in a DataTable.

BTW.  I tried your example, and it gives me:
An error has occured while processing TextBox 'txtBody': 
Missing operator before Joe operand.

In any case, I'm not sure we have a real-life example.  What we have, right now, is a report-generating module that runs the queries, collects the data, and returns it in a number of formats.  We display the html format on a web page, use it to print or create a fax, we use either the plaintext format or both the html and the plaintext formats when sending emails, depending upon whether the recipient wants html in his emails or not.

We're experimenting with using your reporting tool to display these reports.  Our first, quick-and-dirty attempt was simply to dump the entire contents of the plaintext format into a single TextBox.  We didn't expect that to give us the look we wanted, but we figured it would be a starting point.  And it was, except it gave us this odd error if the plaintext format started with '='.

My guess is that we'll probably extend the report-generating module to output a DataSet, and run the report from that.  Which would, AIUI, avoid the issue entirely.

In the meantime, I'm doing:
this.txtBody.Value = String.Format(" {0} ", args.detailData); 

It shifts the text, a bit.  But it will work for now, until we decide exactly how we'll really handle the problem.

Tags
General Discussions
Asked by
Jeff
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or