Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Somehow for this code I'm getting an error, any workaround?

C#
protected void calArticles_SelectionChanged(object sender, EventArgs e)
{
    SqlDataSource1.ConnectionString = 
        System.String.Concat(
        "SELECT [Timestamp], [Subject], [EntryText] FROM [Article] WHERE [Timestamp] = "
        ,calArticles.SelectedDate.ToString + ";");
        
}


Error Message:
Error 2 Operator '+' cannot be applied to operands of type 'method group' and 'string' c:\inetpub\wwwroot\Jon's Couch\Articles.aspx.cs 24 14 http://localhost/Jon's Couch/


:confused:
Posted
Updated 27-Aug-10 12:40pm
v3
Comments
AspDotNetDev 27-Aug-10 18:40pm    
You've used PRE tags correctly in the past, but you didn't for this post. Why is that? In any event, I've fixed it for you... to see what I did, click "Improve Question" and you will see the PRE tag and BLOCKQUOTE tag I used to format your question nicely.

1 solution

ToString is a method. Use () to call a method, as in ToString(). Buy a C# book and read it. You should also not be string mashing SQL in your presentation layer, not if you want to write scalable and maintainable code.
 
Share this answer
 
v2
Comments
Shawn Aune 21-Nov-13 10:02am    
Dear, Christian Graus... I recommend you go buy a book on manners and read it.
Christian Graus 23-Nov-13 3:18am    
So you think it's good manners to ask the most basic of questions without first learning anything, including what the most basic error messages mean ? Wow.
jon-80 28-Aug-10 8:42am    
"You should also not be string mashing SQL in your presentation layer, not if you want to write scalable and maintainable code."
I agree, it's bad design, however, this is just a personal blog, so I'm taking a minimalist approach to prove the concept works :) How would you suggest passing the SQL statements to the database?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900