Question

I am trying to query the database to get the result if the condition of the where clause is correct but I think i queried the wrong way. It has an error of cannot implicitly convert type string to PhoneApp.Budgets. What have i done wrong here. Below is my code:

DateTime dt = DateTime.Parse(expenseDate.Value.ToString());
monthsGet.Text = dt.Month.ToString();
yearsGet.Text = dt.Year.ToString();
string monthBud = monthsGet.Text;

IQueryable<Budgets> bud = from MonthBud in c.Budgets where MonthBud = monthBud select MonthBud;

budgetAmount.Text= bud.ToString();          
Was it helpful?

Solution

As you mentioned in comment 'Budgets' is the database table's, means its a business logic class. And MonthBud is a field of table which is string type. That's why you getting error. May this will help you.

var bud = from MonthBud in c.Budgets where MonthBud = monthBud select MonthBud;
budgetAmount.Text= bud.ToString(); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top