Writing SQL code
Im not used to coding with SQL i wrote a code in C sharp but im not sure how and where to implement it into my current database any help appreciated
23 Replies
What is your question, actually?
How can you use SQL to make your C# application query the database?
its more that i made a code on c sharp and am trying to find a way to make it work for my database so it is like a interactive database
So, just connecting your C# project to an SQL database?
im really new to SQL and dont understand it very well
if thats possible
Sure is
SQL is just a language for "talking" with databases, or issue commands to it.
C# has plenty of ways to do that.
If you want to write SQL specifically, Dapper can let you execute SQL commands on any given database
If you want to not write any SQL, Entity Framework Core lets you connect to an SQL database and will generate SQL queries for you, from your C# code
did you go through the resources provided the last time you asked this question?
yea i did but it didnt make much more clear for me ill behonest i was able to do the questions but its when i try to implement them myself my brain goes blank on how i should do it
where specifically are you getting stuck?
have you connected to your database? can you make some queries but not others?
i have my database open i havent tried running any queries as i dont think its acc functional its more just the framework of it if that makes sense
i mean in your C# code
i dont know how to acc connect it i was going to try se if i can use the Enitiy framework core that zzzzzzzzzz recomended
i thought this was a school project, do you have specific requirements about what to use?
your teacher should be giving you that kind of information
he isnt the best teacher ill be honest i think he just wants it done aslong as there is no plagerisum
EF is more... "magical" than the alternatives. If you have a poor understanding of databases, SQL etc I'm not sure I'd recommend using EF
you wont really understand whats going on
you need to know how databases work before being able to use EF properly
the conclusion we came to earlier is something more basic like ADO.NET is what you should look at
Unless the teacher specifically requests ADO, I'd at least go with Dapper
.Query<Person>("SELECT * FROM People LIMIT 1")
will be much easier to understand than the reader.ReadInt32()
tomfuckeryits not really either or. Dapper is just a thin wrapper on top of ADO
but I agree, use dapper
even better, ask your teacher before you make an assumption :when:
that too :p
100%
True im gonna during the next lecture thank you for the help