I am doing a C# project and I have the following scenario:
The first is for the month, the second is for the year and a button by the side. I also have a table which contains two columns named date (datatype small datetime) and price (varchar).
I have generated this but it errors with “Invalid column name ‘yourMonthSelected’ and
“Invalid column name ‘yourYearSelected'”.
is my approach the right way?
I think you query text is wrong. You tried to add
yourMonthSelectedandyourYearSelectedas a parameter in your query, but you didn’t specify them in your query with@yourMonthSelectedand@yourYearSelected.Try this query;
Look at
AddWithValuemethod and check how you can use it. And you can write;instead of
Which they are exactly same but first one looks better. Also in your while clause, you should use
rdr[0]instead ofrdr, becauserdris anarray. Like this;