Connecting C# To MySQL Using Blazor (Full CRUD Actions)

  Рет қаралды 88,598

IAmTimCorey

IAmTimCorey

Күн бұрын

Пікірлер
@dickybird08
@dickybird08 4 жыл бұрын
Between KZbin and my IAmTimCorey courses I’ve seen this process so many times... but Every time I learn a little more about constructors, classes, dapper, sql dev, using statements, mapping, etc... the understanding that this guy gives us is invaluable. This is something like khan academy for C# ... Believe it or not but you are watching one of the best parts of the internet. thank you man 🙏🏻
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad my content has been so helpful.
@hory-portier
@hory-portier 4 жыл бұрын
I truly agree with you here.
@josephlewis347
@josephlewis347 3 жыл бұрын
i realize it is pretty randomly asking but do anybody know of a good place to stream new series online ?
@archersamson254
@archersamson254 3 жыл бұрын
@Joseph Lewis try Flixzone. Just search on google for it =)
@blainetripp2951
@blainetripp2951 3 жыл бұрын
@Archer Samson yup, I have been using flixzone for since march myself :)
@manuthpemmawadu2201
@manuthpemmawadu2201 3 жыл бұрын
dude i searched the internet for so long and finally i got to the right place. Man, if any out there is watching this, dude you are at the right place. Mr. tim corey keep up the good work.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I am glad it was helpful.
@HemmingEducation
@HemmingEducation 2 жыл бұрын
This was brilliant! I've looked at so many videos trying to figure out how to do this but yours was concise, accurate and well presented. You made it look simple to use blazor with a database which is not always the case with other KZbin tutorials. Thanks!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@kristoffermg5986
@kristoffermg5986 Жыл бұрын
Totally agree, Tim never fails to accurately explain topics without leaving you confused
@kristianrincon1576
@kristianrincon1576 2 жыл бұрын
Thanks for the video, I had looked at other tutorials but none of them worked, until I found your channel.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I am glad it was so helpful.
@bobDotJS
@bobDotJS 4 жыл бұрын
I switched from .NET to Node a few months back and fell in love with VueJs/Node/TS... But there's no way I'm not taking full advantage of this tutorial to Make myself more valuable to employers. My eyes just lit up when I saw this. Thank you Tim!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@kent8695
@kent8695 Жыл бұрын
Thank you, very helpful video, 29:36 - you can wait for it like this List rows = (await connection.QueryAsync(sql,parameters)).ToList();
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Yep. I just find it easier to separate it into two steps because it makes debugging easier.
@phillipmartinez4683
@phillipmartinez4683 Ай бұрын
Just what I was looking for. I had to figure out a couple of things on my own, but everything still worked. Thank you for the great content.
@IAmTimCorey
@IAmTimCorey Ай бұрын
You are welcome.
@zoltan.halasz
@zoltan.halasz 4 жыл бұрын
It's my favorite kind of tutorial: focused, not overbearing and contains new information. I like dapper and blazor server 😊
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad you enjoy it!
@hory-portier
@hory-portier 4 жыл бұрын
I just figured out how many lines of code I have needlessly written in recent months while working with MySql myself... On the other side you just saved me from wasting even more time and space in the future. I need to do some refactoring this week. Thanks.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it helped.
@garethcairncross3269
@garethcairncross3269 4 жыл бұрын
This is the first of your vids I've watched and I got say we'll done! Like Einstein said: If you can't explain it simply, you don't understand it well enough. I've been struggling with this topic for a few days and your tutorial has cleared up everything for me!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad it was helpful.
@platinasEreviews
@platinasEreviews 3 жыл бұрын
been looking for a while on a lot of places and this one was the most helpful and straight video i found. Thanks!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Excellent!
@johecht7872
@johecht7872 4 жыл бұрын
Big thank you from me. I needed exactly this for my project and you uploaded this video on the exact same day. I was really frustrated, that I wasn't able to find something good and then you uploaded your video.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it helped!
@annasahebrahane5879
@annasahebrahane5879 3 жыл бұрын
Awesome tutorial, very simple & sweet language Successfully created demo by watching this video without any error or bug Thank you so much
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for growing your skills with this video.
@bobDotJS
@bobDotJS 4 жыл бұрын
Hey Tim. I actually learned to code using your WinForms videos. I took that knowledge and learned Node & Vue and I'm launching a product in the coming weeks which is over 2,000+ hours of code deep but I consider C# and .NET to be imperative to my general 'computer science' understanding. This video has been on my 'todo' list for nostalgia's sake although I don't get to play with C# much these days, I needed a day off from my project and thought this tutorial would help me unwind. I managed to modify the code a bit and connect to my production server/database and I added appsettings.json to .gitignore. Now I have a great template for Blazor/MySQL which can be a lot of fun in the future. Blazor actually feels like a mix of React & Vue which is pretty cool because I like both. I've noticed a trend that a lot of .NET developers eventually gravitate to Angular. I'm sure as people get more comfortable with Blazor that will change but I've always wondered why .NET devs tend to gravitate to Angular. I've seen it more than a handful of times. Is it that Angular has more of an 'Enterprise' feel than it's counterparts? Just wondering your take on that.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad my videos have been so helpful. As to why people seem to gravitate towards Angular from .NET, I'm not sure. It may be a market thing. They see Angular jobs and they start pursuing what is more prevalent to them.
@bohuang3122
@bohuang3122 2 жыл бұрын
Wonderful video from which I learned so much. Thank you Tim Corey for your effort!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@thangpham5864
@thangpham5864 4 жыл бұрын
Keep up the good work you're amazing! I can't seem to get my head around C# until I discovered your channel!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Welcome aboard!
@jankool01
@jankool01 4 жыл бұрын
I had trouble with the DELETE - permission problem. In MySQL workbench, used Edit / Preferences / SQLEditor - bottom of page uncheck 'Safe Updates (rejects UPDATES....)'. Then worked OK. You did mention in the video there could have been a problem at this point. As always, great video. Best regards. Jan.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad you figured it out.
@Bubinga
@Bubinga 4 жыл бұрын
Wow, great tutorial. I have been working/learning EF core for the past couple months. After a series of complex error messages and struggling to do even basic things, I've decided to move to Dapper finally. I should have listened to you earlier lol
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks for sharing! I hope Dapper works better for you
@davep8695
@davep8695 4 жыл бұрын
Awesome video Tim, as always. Would love to see you take this topic a little further by using some forms for data input and data grids for displaying the data back please. Keep up the great work!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Maybe that will come in a complete application series.
@Gramr98
@Gramr98 4 жыл бұрын
0:29 "My goal isn't to entertain you. My goal is to turn you into a world-class developer" - Well, imo you manage to do both at the same time. You educate us in an entertaining way and explain very clear. Really good job. Could you also make a video how to access multiple SQL 'types' such as TSql, MySql, Sqlite in the same project without using an external framework (e.g. because you aren't allowed to), but with the default classes instead? You know, SqlConnection, MySqlConnection, DbConnction, SqlCommand, MySqlCommand, DbCommand, etc... Or if that's too much, a simple video about the Managed Extensibility Framework would help as well. I'm really stuck with that.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not sure if Dapper qualifies as an "external framework" but the C# Application from Start to Finish course does something like this - it sets up both SQL data access and Text file data access and allows you to choose between the two via a toggle. I'll add your vote for MEF to the list.
@adamv2628
@adamv2628 4 жыл бұрын
well thought through and well explained. i like it a lot and learn to see things come together at the same time. thanks for this talk.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@w123au
@w123au 4 жыл бұрын
Simply Amazing !!!! I use the same steps to connect my application to the Oracle database. Hats off !!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Great 👍
@alainstross3108
@alainstross3108 4 жыл бұрын
Thanks for all your video Tim, and also thank you for your clear diction. English is not my birth language therefore I can perfectly understand you.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are very welcome
@bhuwanmaharjan397
@bhuwanmaharjan397 4 жыл бұрын
First: scheduled to watch tomorrow early morning. NZ thx in advance Tim.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@CRBarchager
@CRBarchager 4 жыл бұрын
50:00 when ever I create an update statement I always type "Update set where" and then go back and edit what ever I need for that to work. That way I never miss the 'where' and overwrite the whole table since if I was to try and run it with "update person set firstname='bob' where" the query will fail since there is not value set after where. I little tip I got from a colleague at my first developer job. Kind stuck with me and since I've taught others to do the same. I normally don't use delete that much in my day to day work but you could use that tip for delete queries aswell "delete from where" and continue from there.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks for sharing.
@bunkie2100
@bunkie2100 4 жыл бұрын
I’ll go you one better. I *always* write UPDATE statements as SELECT using my WHERE clause first. That way I get a visual check on the records affected by the UPDATE.
@CRBarchager
@CRBarchager 4 жыл бұрын
@@bunkie2100 I never really got the hang of it that way. I guess I just need to try it for a longer period. I see the benefits of it. I see some of my colleagues do it that way too. I have usually already made a select statement beforehand so I know the result.
@dardar9482
@dardar9482 11 күн бұрын
feel lost when learning , but TimCorey explaination heal my curious
@IAmTimCorey
@IAmTimCorey 10 күн бұрын
I am glad it was helpful.
@mazharpatel784
@mazharpatel784 4 жыл бұрын
Thanks for your video. Dapper seems much more easy to learn and implement than EF. Please can you also do a video showing how to display data in datagrid and how to generate Reports.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks, added to the topics list.
@TwoThr3e
@TwoThr3e 3 жыл бұрын
Exactly what I needed. Thank You very much!
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for looking to Tim when you need help skilling up!
@X400DYL
@X400DYL 4 жыл бұрын
Superb as always Tim :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks!
@stephanmayer8576
@stephanmayer8576 2 жыл бұрын
in the new vs2022 version is no startup.cs. where do i need to add the services? in program.cs it won' work
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
It will work in Program.cs. Here is a video on how to do it: kzbin.info/www/bejne/rJXLd6pni7iirck
@stephanmayer8576
@stephanmayer8576 2 жыл бұрын
@@IAmTimCorey hi. Thx for answering. I tried it. I wrote the services.builder.........dataaccess line in the right place, and then the blazor app don't run anymore. I can't find another reason, because, when I comment the line out, the app works.
@torrvic1156
@torrvic1156 Жыл бұрын
Thank you so much Mr. Corey! But I’ve got an issue. I am using .NET 6.0 (Long-term support) and I figured how to deal with Program.cs instead of missing Startup.cs but CRUD buttons are not working in a situation similar to the one you had and developer’s panel tells me that connection should be opened and valid. Thus I added connection.Open(); to methods in your library and now it works but still it gives me errors sometimes telling that another read operation is in progress or something like this. So I want to ask you if you didn’t forgot to add connection.Open(); line in your SaveData and LoadData methods of DataAccess library or maybe I am doing something wrong? Without this line it just doesn’t work at all.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
At 18:10, if you look at lines 15 and 25, those lines are actually creating the connection to the database. You don't need to call open. to get this to work. If you call open, it will probably cause an issue. Also, in your case, it sounds like you are opening a connection and not closing it. That's a major issue, since that causes long-term issues for your database. I'm not sure what version of .NET this code was built upon, but this code works for all .NET versions from .NET Core 3.1 through .NET 7. So if it is having an issue, it is probably a small detail you missed.
@torrvic1156
@torrvic1156 Жыл бұрын
@@IAmTimCorey thank you for the response, sir! I found an answer to my question. Some guy in the comments had exactly the same issue and you wrote him that he need to add await instead of return in SaveData method. For some reason code does not hit the end of Using. I did like you wrote by adding await and now it works fine.
@Foodies-pv7ih
@Foodies-pv7ih 4 жыл бұрын
Hi Tim cory! i want you to talk about cross cutting and Aspect oriented prgramming with c#, how to handle it, best practices, thanks
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks for the suggestion.
@Foodies-pv7ih
@Foodies-pv7ih 4 жыл бұрын
@@IAmTimCorey thanks i hope you will consider my request
@oranuzrad8832
@oranuzrad8832 5 ай бұрын
Hi Tim, I watched other video of yours and got wiser by them. I see that this video was created 4 years ago. Do you think it is still current today?
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
There will be slight differences, but most of the code will be exactly the same today.
@mikavesasto3371
@mikavesasto3371 4 жыл бұрын
This is awesome. Thanks. :) I love the tooling MS giving us. It has everything included and core apps can be run on Linux machines, but the MS SQL Server is the only limiting factor. You can't really use it outside of Azure and it's too expensive for personal projects. The free tier isn't enough for real-world personal projects that would be alive over 12 months. MS SQL is really good and would love to use it. Especially loved how you used database projects with TimCoRetailManager. I've searched, but couldn't find any way to use that for MySQL/Postgres. The only add-on I did find was dbForge Fusion for MySQL, but it costs like a $300. Can't really afford that for personal projects.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Well, for personal use, you can use SQL Server Developer Edition, which is free. There is also a version of Microsoft SQL that runs on Linux. Check out this video of running SQL on Docker (on Linux): kzbin.info/www/bejne/j5uZapaNeqySj9E
@leogarza5022
@leogarza5022 3 жыл бұрын
Thank you IAmTimCorey! I was wondering. Can we execute a store procedure rather than write down our query? For example: Datable g = access.getPeople();
@xoanxose4715
@xoanxose4715 4 жыл бұрын
Thank you for sharing the knowledge and doing it so well.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
My pleasure!
@faicalammisaid3705
@faicalammisaid3705 2 жыл бұрын
timy u c sharp legend lol thanks alot
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@angkolkagaw
@angkolkagaw 4 жыл бұрын
I love you tim.. You help a lot.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks
@aiiqwtzhxsuenfjtd1937
@aiiqwtzhxsuenfjtd1937 8 ай бұрын
I recently discovered your channel and really appreciate your work! But i had a few question relating to this section: 43:33 Why doesn't it work in blazor web assembly version? Is it because it compiles to web assembly and web assembly just can't? Also, is there any way to do it another way then? I understand that, even if it would work it woult be very bad practice (even if it WOULD work) to call the database client side, don't get me wrong.
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
WebAssembly runs fully on the client side. That means that the client can fully view our code. So, we cannot put any secrets in our code. That's why we don't access secure databases (just caching databases) from WebAssembly. Instead, we use APIs as an intermediary.
@willinton06
@willinton06 4 жыл бұрын
I felt the temptation, but you went for that Interface, nice.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad you enjoyed it.
@kandy1249
@kandy1249 3 жыл бұрын
I loved your tutorial.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@kandy1249
@kandy1249 3 жыл бұрын
@@IAmTimCorey do you have a discord server? I'm learning c#. I like this language but there's so much to learn. This tutorial really helped me when i was just searching for a connection string that would work. Is there no way to find the connection string that you need? I also realized instead of using "user id=", you can also use "uid =" I was thinking if you can use "localhost" instead of 127.0.0.1
@kandy1249
@kandy1249 3 жыл бұрын
@@IAmTimCorey also, I use linux KDE neon as my main OS. I don't have that legacy of "visual studio" as it's not yet available on linux. So i use visual studio code. Do you even have a tutorial on entity Framework? And if yes, is it linux user-friendly tutorial? Like can you do it all on visual studio using dotnet CLI? Here's a request, can we do a whole Blazor project including restful API, UI, backend, database all being done using visual studio code, dotnet CLI?
@jackkendall6420
@jackkendall6420 4 жыл бұрын
Hi, Tim. Apologies for this not being related to the video, but what are your thoughts on doing a video about reflection? I think I get the general idea but the finer details and necessity of it somewhat escapes me. Apologies if you've already made something on the topic, I didn't find anything.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I will add that suggestion to the list. Thanks.
@iuliandutu4001
@iuliandutu4001 4 жыл бұрын
Really helpful video. Thanks!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You're welcome!
@coding_ideas
@coding_ideas Жыл бұрын
Hello Sir, thank you for this video! I am currently in the process of learning how to develop Blazor server applications and I have been able to make some progress by implementing basic CRUD operations. However, I am concerned about the security implications of passing IDs to another page without using local storage. Is there a recommended method for achieving this? , do you have any instructional videos on this topic that you can recommend?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Local storage isn't going to increase your security here. That is fully available to the client to manipulate. You need to do security checks on each page and for each action anyway, so passing IDs isn't a security risk.
@pedroferreira9234
@pedroferreira9234 4 жыл бұрын
Hi Tim, thx for the video. Two questions, why not use ToListAsync() in LoadData ? It's because the overhead that come with async/await?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Correct. I did not see the async to be that valuable when the data was already on the machine. This call is valuable when you have an IQueriable where the ToList actually performs the call and downloads the data.
@johncraig5979
@johncraig5979 4 жыл бұрын
Thanks Tim for this video. I was building a project with EfCore with clean architecture, but wanted to refacter EfCore use with interfaces... looks like I can now use Dapper for reads and EfCore for writes if I get this right.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Why have two ORMs? Use Dapper for both.
@johncraig5979
@johncraig5979 4 жыл бұрын
Ah, right. Noted. But that now begets how to replace a dbcontex class and a migration rub in the program class that creates the db and applies a migration upon startup of the application. I guess that might be my suggestion for another video down the road. Of. Ourse, I think I can solve this with the previous Blazir video that was a couple of months ago that showed us a IDatabase interface.
@mikeb6006
@mikeb6006 3 жыл бұрын
19:30: It will be more cleary and clean if we create a folder "Components" and "Pages"? Why you mix components and pages in same folder "Pages"?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Because every page is a component (and we treat them that way). It sounds clean to separate them but the separation has more chance to confuse rather than clarify.
@mikeb6006
@mikeb6006 3 жыл бұрын
@@IAmTimCorey i see. Thx Tim!
@kiembui6942
@kiembui6942 4 жыл бұрын
I am using this video to learn Dapper CRUD actions, but using a wpf .net Core application to test instead (I want to get the data layer down first). When using the connection.ExecuteAsync method I get an "Invalid operation. The connection is closed." exception. I noticed this problem goes away when I change the "using IDbConnection connection = xxx" to "IDbConnection connection = xxx" . It seems the async operation is closing the connection before the actual execution is complete. monitoring the sp_who in SQL Server Management Studio, I can see that removing the using portion of the statement does not leave any hanging open connections. Is this still dangerous practice, and is there some sort of special case with the a desktop application vs a blazor server app? Thanks for your videos they're great! edit: forgot to mention the using portion works fine for loading data, it is only the executing of queries that gives me the closed connection exception. I suspect this is because the LoadData function awaits the connection.QueryAsync and the SaveData does not await anything, just returns the task. thanks again!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I've not come across this issue when using async. That's odd. I agree with your hypothesis. It is concerning that the using statement is closing before it is done. I'm guessing I should have done an await on the SaveData. You will need to await the task so that it completes before the statement is closed. So if the insert takes too long (meaning it doesn't complete before the next line), it will close the connection. My code probably has the bug. The using statement should not be closed before the operation completes.
@kiembui6942
@kiembui6942 4 жыл бұрын
I see. Would you recommend structuring the methods to return Task with no using method, or changing all the methods to async voids and use the using method? Followup question for my own education, if I'm seeing no hanging connections in the SQL Management Studio what are the real dangers of not making sure to utilize the using statement? edit: I decided to play it safe regardless and just changed all of the offending methods to async voids or async tasks and added awaits and put the using statements back in
@lloydhotchkiss7269
@lloydhotchkiss7269 4 жыл бұрын
When we publish a project with a data library what folders do we need to include on the server in order to execute the application? The publish process produces one release folder for the Data library and one for the blazor project, how does the blazor project access the data library? If you have any tutorials on migrating this to a linux vm please let me know, great video thank you for your thorough explanations.
@luismendez9436
@luismendez9436 4 жыл бұрын
Thanks, just what I needed.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad I could help!
@bullcarr
@bullcarr 4 жыл бұрын
You’d mentioned adding the models to the library would it be better to do that as well as have classes with methods in library for the save/load ie _data.people.savedata(person) or _data.people.update(person) ? With the sql and connection string all in the library?
@hfpsc27
@hfpsc27 4 жыл бұрын
Hi Tim, great content, off course! In Blazor we don't use controller or "code behind" like razor pages?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Blazor uses the MVVM pattern.
@amanazad4028
@amanazad4028 4 жыл бұрын
Thanks bro i have learned alot.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad to hear it.
@Glip96
@Glip96 Жыл бұрын
Hi Tim. thanks to yuo i'm using dapper and loving it. I have to change a blazor server app to blazor client. Every thing wen ok until i started to connect to mysql. In server everything its ok. In blazor client the mysql driver threw an exception in any operation even when i open te connection. ¿Have you use blazor client with mysql? its that posiible?. Thans in advance
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Blazor WebAssembly runs fully on the client side. That means that your C# code goes to the client. The client can read all of your source code (this is the same way Angular, React, and Vue work). That means that we do not want to put any sensitive information in our code, including connection strings, nor do we want to give direct access to our database. That is why we use an API with any client-side application like Blazor WebAssembly or React.
@benjaminvitek2583
@benjaminvitek2583 3 жыл бұрын
In the other video you did "Blazor Server Side ..." you used services.AddTransient(); instead singleton like in this vid. I know the difference, but wonder what reason there might be to use one other another. P.S i use cosmos if this might change anything. And thank you very much for your vids.
@michaelangelomerza3966
@michaelangelomerza3966 3 жыл бұрын
Just a newbie question. Does this method not prone to cyber-attacks like SQL Injection?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
That's a good thing to consider. In this case, no, it is not vulnerable to SQL injection. SQL injection is when you allow the user to impact the query string in an unsafe way. For instance, providing input that would terminate the query early and potentially run a new query such as "select * from People where FirstName='%';Drop table Person;" or something like that. In our case, we are not asking for user input so our queries cannot be manipulated like that. Also, even if we did ask for user input, we are using query parameters (the "@FirstName", etc.) This allows us to place the contents of what the user gives us into the query properly and reduces the possibilities that they can pass in code to disrupt our SQL statement. However, we should still be cautious to clean the data from the user before accepting it to be doubly certain we get good data.
@michaelangelomerza3966
@michaelangelomerza3966 3 жыл бұрын
@@IAmTimCorey I see. Thank you. I am learning a lot from you.
@Funkfreed
@Funkfreed 4 жыл бұрын
Excellent as always Tim. I watched the Blazor Server with SQL access tutorial as well the other day. I noticed that on that one you created an entity(or model?) for the data access library together with the sqldataaccess class. Considering that both are Blazor Server project. Which one do you think is better in terms of design? Also, when I run my app that connects to MSSQL DB it takes a long time to connect and show the list of users, I changed the access from transient to singleton hoping it would help but it didn't do much. Is this to be expected because MSSQL is not started and is being started by visual studio whenever it tries to run? If so then I think this shouldn't be a problem on a web app uploaded on cloud servers since SQL Server should always be up, am I correct in this assumption? Sorry for the long questions.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am not sure what you are asking in the first question. As for the second question, it all depends on what you mean by a long time. The first time you talk to SQL, it will be a bit slower but it should not be slow. It may be because of your machine's speed or it might be a poorly-written query. I would do some investigating to figure out where the bottleneck is.
@Funkfreed
@Funkfreed 4 жыл бұрын
@@IAmTimCorey thanks I'll do that. The query is a simple select on a 5 row table. I'll try starting the sql server prior to run and see if that makes a difference
@adamv2628
@adamv2628 4 жыл бұрын
you mentioned at the beginning of this video that you use Blazor server for calling mysel. as you cannot call to mysql from blazor webassembly as you said. my question is then what solution would you use to call to a backend like mysql from a blazor webassembly app?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You would put an API in between.
@adamv2628
@adamv2628 4 жыл бұрын
@@IAmTimCorey Thanks!
@Chepaco25000
@Chepaco25000 3 жыл бұрын
Hi Tim!! Is there a course on your website for MySQL and C#? More specifically MVC?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I don't have a MySQL course. However, don't get too stuck on "with MVC" since the UI should not have any affect on the database used and the data access code from a Blazor Server project or WPF project should work the same in an MVC application. I cover that in more depth here: kzbin.info/www/bejne/aGXMpp2jaZ6sZ5I
@megamerchannel2060
@megamerchannel2060 2 жыл бұрын
Hey Tim, I've recently started working on a project that uses blazor. So far I'm having difficulties connecting the WebApp to a local sql db. Documentation and tutorials, even this video have not enabled me to figure it out. I was wondering if you had some advice? Kind regards. Extra Info: Using .NET 6 & VS 2022 Blazor WASM + ASP.NET Core Hosting + WPA Currently in early development fase => trying to use local SQL Server (SSMS) since I've been given a replica from an existing database
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
This depends on what you mean. You can definitely connect your ASP.NET Core Hosting project to a local SQL database if that local SQL database is local to the web server that you are running on (meaning the same machine). You cannot access a local SQL database from another machine (at least not easily - you would need to open multiple firewall ports and use the IP address of the server). So if you are doing things on the same machine, just check your connection string. That's probably the problem.
@pgnutz
@pgnutz 4 жыл бұрын
Great videos and very practical. Would you have an example using Blazor+Dapper+Oracle?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I don't yet, no.
@Chris-Brown-
@Chris-Brown- 8 ай бұрын
wow a 3 years old tutorial that still works
@IAmTimCorey
@IAmTimCorey 7 ай бұрын
👍
@gavranhas
@gavranhas 3 жыл бұрын
thank you, Tim
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@abdelkiki
@abdelkiki 3 жыл бұрын
Thank you Tim
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@zensic
@zensic 3 жыл бұрын
Many thanks sir!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@hasanpkb
@hasanpkb 3 жыл бұрын
Very informative. How about a tutorial on Sybase Central SQL Anywhere ? Have you tried to connect with Blazor? Thank you
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@devgenesis6436
@devgenesis6436 4 жыл бұрын
@Tim when u will going to put up some cloud videos(aws or azure) ..is it on ur list in this year?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I do have quite a few videos on Azure in some form or another: kzbin.infosearch?query=azure Some of these are for Azure DevOps but I also deploy to Azure Web Apps, use Azure SQL, and set up Azure Functions.
@lemorlenny
@lemorlenny 3 жыл бұрын
Great video!, I have a trivial question, how can I send an explicit long query string with JOIN etc.? , thanks
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Just like you would with a select statement. I do not believe there is a length limit on your query.
@michelchaghoury870
@michelchaghoury870 4 жыл бұрын
tnx alot for your work i am learning alot from you i want to ask you some questions. betwwen sql server and oracle sql itch one is more secured and stronger and please can you make videos about azure key vault or how to build security around dotnet application(web desk) and will you cover MAUI when it will be available and is it cross platdorm (compile it once and run the app on linx mac and windows or it will be like wpf and winform only for windows) and will you make mobile app dev in the future?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
SQL and Oracle are equally good at security. I'll add your suggestions to the list.
@analuisacarneiro2183
@analuisacarneiro2183 3 жыл бұрын
YOU SAVE LIFES
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@teemusekki1743
@teemusekki1743 4 жыл бұрын
Yes this is what I'm looking for
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad to hear it.
@didiksupriyadi9740
@didiksupriyadi9740 2 жыл бұрын
Awesome video Tim, How to add method return single object
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I believe you are asking about my method that returns data from the database. Right now, it is a List. If I want to return one record, I still return a List because then I can use the same method. However, if you want to lock into returning just one item and you don't want to return a list, just create a wrapper method that makes the "normal" call and then gets the returned List and pulls out the first record (or default if none) and returns it.
@didiksupriyadi9740
@didiksupriyadi9740 2 жыл бұрын
@@IAmTimCorey Thanks for the answer, you are right, ... can i use identity asp in Blazor with dapper without EF Core?
@dobiqwolf
@dobiqwolf 4 жыл бұрын
Hello Tim, Thank you for a great video, I am currently working on a project and this helped me lots however at 47:20 you mention the use of Insert Form, I am struggling with that topic and merging it with searching MySQL DB. Would you have a video that make sense on how to add the search option using insert form? I have already created the whole page using Bootstrap, I just cannot link the input text to the "where" in my "select" command.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
To add a where clause, you would do something like this: "select * from people where LastName = @LastName" and then pass in a LastName parameter (like we passed parameters into the insert statement). You would call the LoadData instead of the SaveData though.
@dobiqwolf
@dobiqwolf 4 жыл бұрын
@@IAmTimCorey Thank you for the fast reply. My main issue is how to I get the string from the input box I created to XXXX below. people = await _data.LoadData(sql, new { LastName = XXXX }, _config.GetConnectionString("defautl")); I have been searching everywhere online but I get so many different results that I just don't understand. My inputbox code looks like this: and the button looks as below: Search
@ahmedkhudhair8035
@ahmedkhudhair8035 4 жыл бұрын
Very useful thank you 🙏
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@ichibanraider6653
@ichibanraider6653 2 жыл бұрын
ArgumentException: Format of the initialization string does not conform to specification starting at index 54
@rajneshp
@rajneshp 4 жыл бұрын
Very informative. How about a tutorial on MongoDB.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Here you go: kzbin.info/www/bejne/bGq6c6xqgq2Mi9k
@rajneshp
@rajneshp 4 жыл бұрын
@@IAmTimCorey thanks
@ryansatchell2302
@ryansatchell2302 4 жыл бұрын
Design question: In a live scenario, would you strip all of that specific data logic(i.e. People Model, query, params, call to dataAccessor) out of the blazor page and into, for example another class Library or seperate folder within the Web project?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It depends on the situation. This might be the same as what I would do in production or I might add a bit more separation.
@ryansatchell2302
@ryansatchell2302 4 жыл бұрын
@@IAmTimCorey gotcha. Thanks for the reply!
@pilotboba
@pilotboba 4 жыл бұрын
Nice demo. Although, all the cool kids are using MariaDB. :) Would it make more sense to handle the connection string in your injection so you don't have to deal with that in the UI code?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Potentially but that means you need to have a uniform way of accessing it. If some clients use IConfiguration and others don't, that would cause an issue in your class library. This way was simple and will work for any number of UIs.
@hkon79man
@hkon79man 2 жыл бұрын
is this video series include client server (API) sample project version?
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
What video series? This is a stand-alone video covering MySQL in Blazor Server.
@euihoo
@euihoo 4 жыл бұрын
I like your video. I have a question. Can changes be displayed directly on the web as the database changes? Ask me what to do.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You could do that with Blazor and some monitoring of the database, yes.
@mohammednihad6755
@mohammednihad6755 4 жыл бұрын
Hi sir, I have a windowsforms app build with C#, it connects with a MySql database to store and retrieve data, I use Mysql.data for that, it actually runs on local host where the database exists too. But every time I need the app, I need to run XAMPP first so that I can connect to the database. Is there a way to connect to the database directly from the app without using any extra software? Thanks for your great content 💙
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
As long as your MySQL server is still running, you can connect to it directly, like I did, instead of having all of XAMPP running.
@mohammednihad6755
@mohammednihad6755 4 жыл бұрын
@@IAmTimCorey Thanks for your replay sir 🌹 What I mean is: now, my customer needs to install XAMPP in addition to the software I wrote, and every time he reboots his system, he needs to deal with an extra program -wich is XAMPP again- which kinda doesn't make sense for him.. Is there a way to create and run a MySql server with my C# code (maybe a library or a custom package) so that I don't need to use an external software? Thanks again 🌹
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not MySQL, no, but check out SQLite. It can be self-contained rather than needing a database engine to power it.
@mohammednihad6755
@mohammednihad6755 4 жыл бұрын
@@IAmTimCorey Thanks a lot 🌹
@dirganaratama970
@dirganaratama970 4 жыл бұрын
Hi Tim, Thanks for you Videos. Awesome Do you have video about Authorized?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not specifically, but see if these add value - kzbin.infosearch?query=authent
@rgry
@rgry 3 жыл бұрын
I'm now at section "Dependency injection (startup.cs)" but there is no startup.cs in my BlazorServer project? Where to put the injection now? I try to put it in program.cs where the WeatherForecastService is
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
If you are using Blazor Server, it sounds like you are using the new .NET 6 Blazor Server. If you use the Blazor Server from .NET 5 you would see the Startup.cs. No worries, though, since you figured out the correct place to put the code.
@rgry
@rgry 3 жыл бұрын
@@IAmTimCorey Thank you. You are completely correct is is NET 6 and Server.
@padha735
@padha735 Жыл бұрын
Hey! I couldn't find startup.cs file in my latest BlazorServer app. Can you help how to do Dependency injection at 21:27?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Here you go: kzbin.info/www/bejne/rJXLd6pni7iirck
@MarioStaats
@MarioStaats 4 жыл бұрын
Hi @IAmTimCorey. Is it possible to use Dapper instead of EF for Microsoft.Identity and remove all EF-Packages from Blazor-Serverproject? And a small Hint, on 19:07 you made a Reference to your Classlib. With the new Visual Studio, you can drag the Projectname (in this case DataLibrary) and drop it directly on the Entry "Dependencies". In case you not already know it. Your Videos are great and a big inspiration in my daylie works *thumbUp
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It isn't easy, no. I recommend leaving it with EF, even though I'm not an EF fan. Thanks for the tip and the encouraging words.
@cyrildouglas9262
@cyrildouglas9262 4 жыл бұрын
Thanks Tim, even though its a demo but I still think SaveData method could be improved even more, like execute extension method from dapper returns int which is rows affected for the execution, so that I think instead of Void or Task which they are fire and forget you could use int or bool var rowsAffected = connection.Execute(..); return rowsAffected > 0; by any chance it will be great to see a video from you about CQRS as well.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Yep, you could do that.
@kirlisakal9645
@kirlisakal9645 Жыл бұрын
hello, is it possible to pull mobile data with this method? Is the mobile data extraction method different? I'm trying to make a mobile application, I'm new. Thank you from now
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Mobile is different because the connection string cannot be private, so you will need to use an API.
@jvaque
@jvaque 4 жыл бұрын
A way to improve on this is to use stored procedures so you can have only certain stored procedures for different database users. But to do that with the minimum user permissions (GRANT EXECUTE ON PROCEDURE dbName.spName TO 'databaseUser'@'address';) you have to use MySqlConnector, a community MySql connector that fixes known issues in the official MySql.Data. I've been using this for my projects after I addapted the data access class from the TimCo Retail Manager and it's been working great. Also a question for Tim, I'm trying to change the database used in asp.net web apps for authentication to MySql from MSSql. I thought this might be "easy", as in change the connection string, import the necessary libraries for using MySql with entity framework, a few config changes and then let entity framework be in charge of building, modifying and queering the information as the loggin/authorization endpoints made by default that use the entity framework connection are probably more secure than what I'd be able to make. As of right now I've managed to avoid it crashing on startup of the web app but when I call the Api it fails to create the database on the first insertion (like it does when you don't have a database instantiated in MSSql). Any ideas for using entity framework with MySql? I've thought of manually creating carbon copies of the tables in the users database in MySql but don't know if there are any stored procedures/views that entity framework creates when using MSSql that it also uses.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
My guess is that it has something to do with the data types in SQL vs MySQL but I am not sure. Working to change the Identity system can be a tricky business.
@sunnyokoro
@sunnyokoro 4 жыл бұрын
Thanks Tim for the tutorial? How about using MySQL with EntityFramework? Can you also do a video on tht?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Probably not. I don't cover EF since I don't think it is nearly as useful as people think it is.
@fareedali8
@fareedali8 2 жыл бұрын
can you make a video of one to many relationship with one tablet fields include an other table fields
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@andywalter7426
@andywalter7426 4 жыл бұрын
I have a question. How can mysql be the most common on the web. Obviously if you were deploying to azure, the sample would not work because i assume that azure can't connect to your local mysql. I would like to see a video of actually deploying to azure and still seeing it work. Are there any free options for mysql? Because if not, then a person who has no money can't even get experience with mysql then.
@pilotboba
@pilotboba 4 жыл бұрын
I found this... maybe it will help. www.freemysqlhosting.net/
@willinton06
@willinton06 4 жыл бұрын
Andy Walter MySQL is open source so it’s free for everyone, you can deploy hand existing MySQL to azure, or at least you could, same for AWS, and you can just set up the database in an actual server and have it accessible through the inter webs
@gp6763
@gp6763 4 жыл бұрын
Why not simply use an Appache server ? It is the reason why mySQL is so popular, a free software that perfectly work on a free server
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
MySQL is very popular on the web because MySQL runs on Linux (SQL does too, but only recently). So, a cheap web host will be running Linux and MySQL by default. As for deploying to Azure, Azure will run MySQL. Remember, you can also put your MySQL server somewhere else and just change your connection string. As for free options, you are going to get what you pay for. I would not use a free version for a production application. If you are testing, you can test on your machine. You can even open up ports to allow others to see your machine and your sites. You can get tons of experience without deploying MySQL to a production system. Just do it locally.
@satheeshmohan
@satheeshmohan 4 жыл бұрын
Hello Tim, Can put a separate video connecting to Oracle Database Stored procedure with UDT
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@zangetsu2k8
@zangetsu2k8 4 жыл бұрын
is there a good way to implement dependency injection in backend, I was halfway implementing Dependency injection in a web api controller before realizing I've never actually used dependency injection where there wasn't razor components... how does one do that? googling didn't do much for me
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Check out the TimCo Retail Manager series. In it, we implement dependency injection in our API once we upgrade it to .NET Core.
@almirmusanovic513
@almirmusanovic513 4 жыл бұрын
Thank you Tim. It will be so nice if you can provide an tutorial / payed course on how to deploy simple .net web app / web api but on a shared hosting like goDady...because aws / azure are so expensive..for example, i want to build an blog with custom cms..and winforms admin app...and i will buy your full timco retail manager course wery soon...but i cannot deploy my small / beginer level apps on azure...so, i am ready to pay some course on how to deploy 'timco like' apps on a shared hosting. I think that course would be awesome...
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@dirganaratama970
@dirganaratama970 4 жыл бұрын
Hi tim, i got a problem when add DateTime type into this tutorial project. the Date just showing default value (01/01/0001) to web page not from Database value. How to retrive date value from database (Mysql) into blazor web page?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You have a mismatch somewhere. Maybe your property names don't match your column names exactly. This post might help: stackoverflow.com/questions/34412224/dapper-returns-01-01-0001-000000-from-mysql-datetime
@HerrRectum
@HerrRectum 3 жыл бұрын
ArgumentException: Option not supported. (Parameter 'trusted_connection') Is shown when trying to load the people page for the first time :o
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
It sounds like your connection string is incorrectly configured.
@HerrRectum
@HerrRectum 3 жыл бұрын
@@IAmTimCorey Yep I figured it out. Thanks pal. Awesome tutorials btw
@jk02
@jk02 4 жыл бұрын
do you have a tutorial on how to make crud in blazor calling API?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not yet, no.
@logananderson2013
@logananderson2013 4 жыл бұрын
How would you get the last inserted id when you add something to the database with dapper?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It depends on the database, but usually you get something like Scope_Identity() (this is for SQL), etc. Then you either return that in a select statement or you return it as a output parameter. Here is an example of how to do that: kzbin.info/www/bejne/m3zOmWiOopWCorc
@jeffhier316
@jeffhier316 3 жыл бұрын
What is the mod / extension you are using to auto complete using statements?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
That's just Visual Studio. No mods or extensions.
@jeffhier316
@jeffhier316 3 жыл бұрын
@@IAmTimCorey Thank you. I must have missed a setting. Still new to this.
@rogerirwin4022
@rogerirwin4022 4 жыл бұрын
As far as I can tell the 'Loading.....' message will only appear if the data is not fetched correctly and people remains null. The page will not be rendered until the OnInitializedAsync() Task has completed. Perhaps it would be better to say 'Oops, error loading data'.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
That method is Async, so the page can load and display before the data returns. So you will see the Loading... message if the database is slow.
@rogerirwin4022
@rogerirwin4022 4 жыл бұрын
@@IAmTimCorey OK, I'm now understanding more about this Blazor architure, coming from PHP I expected the page to be generated once! What are the specific criteria for recreating the HTML, or does it do it each time an event is passed back and acted on?
Creating Excel Files in C#
55:42
IAmTimCorey
Рет қаралды 130 М.
How to Become a Highly Employable C# Developer in 2025
20:10
Gavin Lon
Рет қаралды 5 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 82 М.
Getting Started with Dapper in .NET
11:29
Amichai Mantinband
Рет қаралды 15 М.
139. What Are Your Thoughts on Entity Framework Core vs. Dapper?
21:49
Java Database Connectivity | JDBC
20:34
Telusko
Рет қаралды 386 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 227 М.