WPF with Database

laugh52

New member
Joined
Apr 24, 2020
Messages
3
Programming Experience
Beginner
Hey guys,
I am really new to C# and had a question to you. In our first lesson in school, we were trying to create a database named food. in this database are tables and we need to create a button in wpf which checks if the table "calories" has only one number in it.
 
wpf.PNG



When I press the Button, it should check if the calories Column has only a single number in it or more than one.
 
Again, what's the actual problem? If you don't know how to query a database then you need to learn how and make an attempt to do so. I would assume that you would have been taught how but, if not, there are lots of places to learn the basics. The generalities will depend on the data access technology you choose, although it's likely to be ADO.NET for a beginner. If you don't know how to use ADO.NET, that's what you need to learn.

Do you know how to perform a query but don't know what SQL to use in this specific case? If so, that's what you need to say. Just telling us what your assignment is and expecting us to take it form there isn't really good enough. We are happy to help with specific problems but you haven't put enough into this assignment to have actually encountered a specific problem yet.
 
we were trying to create a database named food. in this database are tables and we need to create a button in wpf which checks if the table "calories" has only one number in it.
You have more than one problem. You also need to create the database from code. I assume you are using SQLite or some other compact DB. If not, you need to elaborate?

Next you need to create the table. Because their is no way that the value is just going to conjure itself into the database.

And your next step will be inserting the value.

And only then will you be able to query the table to get the value from it.

Until you make an attempt, and show us what code you have actually written, then there is not much more we can do. Surely, you didn't expect us to do your assignment for you? We have no problem helping you, but you need to make an actual attempt first.
 
1587843473233.png

so i cant make such an if statement right there ?
The Error says: The > Operater cant operate a type int and type DataGridTextColumn
 
Have you covered any tutorials on WPF yet?

Take a look at this SO answer to get an idea of what you need to do. It's not perfect but it will get you moving.


It's the reverse of what you are doing, except it's done the same way. Start reading up on data binding, and types in c#. If you are having trouble with types, I suggest going back and covering some tutorials on that subject.

How far have you actually gotten in the steps I outlined on post #5?
 
Back
Top Bottom