Hi Tim, you know the saying you cannot teach an old dog new tricks? Well, you busted that one. You taught this old dog a new trick and it's just marvellous. Thanks man!!!!
Thank you for a great, direct and useful tutorial for SQLite in C#. I am new to SQLite and this video was a real example of a quality presentation with real-world scenarios of using C# with a file-based database system in a contained environment. Well done, sir.
17:26 Relative connection string 19:11 - 21:50 Dependent packages 26:00 Get connection string in library project 29:47 Query list of PersonModel from db 31:50 Write a person to db
@@IAmTimCorey Can you set up a pay method for AliPay? I believe there are many Chinese subscriber like me who what to enroll your course. Most chinese don't use credit cards.
I had to learn a bit of java lately, forcing me to watch some different tutorials, and let me say this, you have achieved your goal. You do make learning c# easier.
0:00 - Intro 1:14 - Demo app overview (win form app) 4:30 - What is SQLite 5:09 - How to create and build SQLite Database: DB Browser for SQLite 11:17 - Database Structure 13:04 - Adding the Database to the project 15:26 - Adding the Connection string 18:15 - SQLite and Dapper NUGet packages 21:58 - Data access setup 28:17 - Retrieving data form DB: LoadPeople() 30:14 - Sending data to DB: SavePerson() 31:51 - Wiring up the Demo app 33:08 - Workings with the Database 36:18 - Summary and concluding remarks
Be sure to check out the whole channel - th-cam.com/channels/-ptWR16ITQyYOglXyQmpzw.html. Use the search icon under the Subscribe button to search within the channel to find the training you need next.
thanks, Tim for all the videos and effort your providing. you are a legend, you are the best teacher ever. definitely, I will have a course with you one day.
Boss ...you are just brilliant ......wooww...every topic explained very clearly.....u know what is missing in daily soap and u just bang on fish eye.....
I know this is sort of outside the scope but, If you want to distribute your application with some tables containing data, I prefer using EmbeddedResource as the compile action and using that to create the db file if it doesn't exist at the specified path. This allows you control when the database file is copied/written. I feel like this offers more control over the database file on deployment when users execute the program. You can offer the user features such and restarting from scratch you can disconnect from the database, delete the db file and replace it with the embedded resource version of the database. Like for example if the database somehow got corrupted.
Tim - "Its not too much to ask a person to give me a first and last name". Maddona- "Am I a Joke to you?! Do I not get to play in your database?" :P J/k, this is amazing and I'm subscribing just because of how well laid out this is. I needed something to explain c# and sql lite but didn't want a 3 hour course, and I needed some basics on the sql lite part as well. You did a great job with this!
Tim, I agree the way of teaching is amazing with slow pace and injecting in viewers mind slowly and nicely. But at time confusing may be because of the method you took up about SQL connections and accessing. In fact I saw better methods in the net without confusion. Thanks any way...
Great video. Thanks. Just to clear my understanding, SQLite is just meant for 1 user, you can't point 2 or more machines to the same SQLite database so they have same data like in full sql.
Thank you so much for this video Tim, I've been looking for a basic video like this for a good few days, the whole SQL localdb vs SQL Express vs SQLite was just far too confusing when I knew SQLite was what I needed, I just couldn't find a video to show a simple connection (ignore me (apart from the thanks bit) as these might just be words from a rambling programming student).
good job beautiful video very easy to understand useful for beginner helpful for manipulate project include sqlite data for mono pc i like your job continue
Great video. But I have a problem with sqllite. It does not handle storage to well. What I mean is that once a data is deleted. It does not use that space again. So the database can get bloated with empty space.
By far the best SQLite in C# example video I saw. The only problem I'm having now is in visual studio it runs fine (debug and release mode), but when I publish it I'm getting an 'unable to load dll 'sqlite.interop.dll'' error.
When you publish, make sure the SQLite interop dlls are going too. I believe they are in a sub-folder under Debug or Release and there are separate DLLs for 32- vs 64-bit.
In .Net Core 3.1 using Visual Studio 2019 Community Edition, you have to download a Nuget Package Called System.Configuration.ConfigurationManager in order to read the app.Config. See video clip at 24:53.
Great course, Tim. I am a new subscriber and I have been learning more from your tutorials than I have on other learning platforms. I encountered an interesting issue with Dapper while coding your demo. It turns out that Dapper isn't a big fan of interfaces so when I tried to be "smart" and created a list of IPersonModel objects, the insert failed. I had to switch my type back to the actual type.
Yep, because Dapper is going to use an actual type to do work. It cannot take an interface because it doesn't know which type to use to do the actual work.
They go in the same place. WPF projects have an app.config file too. If you are referring to WPF Core projects, you would put the connection string in the appsettings.json file (examples of using connection strings with both of these types and more are in the TimCo Retail Manager series).
I was just thinking the same thing with .NET Core and figured it out with a bit of googling. This works: 1. Add "System.Configuration.ConfigurationManager" NuGet-package (instead of reference) - Major change 2. Create App.config with the connection string inside configuration (like in the video, but doesn't have any of the other groups) then set the file to "content" and "copy to output" (like the database file). - Has to be created manually. 3. Rest works like in the video.
How can I use triggers in Sqlite and c#? Is that possible? I don't think so, because sqlite doesn’t work with stored procedured. How do I send values to my triggers without stored procedured?
Unfortunately, you cannot use Stored Procedures in SQLite. You don't send parameters to a Trigger. You automatically have access to inserted, updated and deleted rows when you're writing the trigger code..
@@signo18 No - Triggers are not really triggered by your code. They are triggered by the database when table data is changed. So, even in the SQLite Browser (where you can edit the data in the database), if you change the value of a column that has a trigger on it, the database will automatically execute the trigger immediately.
You could make an extra table for parameters, e.g. TrgParams, and in your table add a column called TrgParamID. Insert parameter in TrgParam table, get its id, and when updating your real table, also set value of TrgParamId column to the new id, e.g. 10. The trigger should fetch the id from the new record, search for the parameter in the TrgParams table, then work based on that.
I love your tutorials, really easy to understand and follow. At the moment i'm struggling with creating and printing custom documents in c# (reports, receipts) . I tried RDLC but it feels kind of clunky . That would my suggestion for a future video.
I love the simplicity if SQLite, especially with WPF development. I’m writing an app now that will allow the user to password protect specific records. For the average user, they won’t know how to open the .Db file, but I can’t help but ask, HOW can I encrypt the SQLite database? I’ve seen mentioned SQLite Cipher, but is that the best way to go when working w/WPF applications? Any suggestions are definitely appreciated! I also feel SQLite encryption would make a great follow up video to your other training on SQLite! Thanks!
Hello Tim Corey. I was wondering if you could please explain why the Database file that we created and saved to the WinFormUI project folder is not written to, but instead another Db file is created in the WinFormUI\bin\Debug directory that is written to? Also, if you have a link to some literature that explains why the Db in the Debug directory is used that would be helpful too. Thanks !!!
The connection string tells the application where the database is. Since the connection string did not specify a path, it assumes a relative path (relative to the executable running the command that uses the connection string). That's why we have to copy the database into the debug folder. Also, by using a copy of the database instead of the one we include with our project, we won't have sample data in the database we give to customers (unless we want it in there).
The reason you need to reference the sql lib also in WinFormUI, is a visual studio bug, that sticks around. I usually use typeof on a class from sqlcore lib in the DemoLibrary, so visual studio see's you actually using it, and doesn't get rid of the .dll, and it doesn't need to be referenced in the WinFormUI.
Hi Tim, i have a question. What is the purpose of the DemoLibrary project? Is that needed or can i have my models and NUGet packages in the UI project?
It keeps a separation between your business logic and data access from your user interface. Putting everything in your UI locks you in by tightly coupling your application together. By using a class library, we can disconnect this and make it easier to upgrade parts of our application without upgrading the entire thing.
There are options, but the easiest one in my opinion is to use a text field. You could use an integer and calculate seconds from 1970 among other options, but those options aren't human-readable when scanning database columns. I prefer just using text and converting it back to DateTime.
@@IAmTimCorey So If We Have A DateTimePicker named as DTP this means we can define string theDate = DTP.Value.ToString("yyyy-MM-dd") OR Something Like This and Then We Should Store THis String onto the DB
Hello, I do not understand why you have to create 2 projects (DemoLibrary and WinFormUI) because, it makes you add twice the nuGet packages? Thank you :)
Hello, thank you for your explanation. This is similar to the MVC, I understand better;) did a series of video to explain precisely how organized his project? I'm waiting for that, the creation of file to "tidy up" these classes, etc., thank you!
I am unsure why you need a second project (DemoLibrary) to do this SQLite thing. Could you do all that within one project or do you need to have two projects to accomplish a SQLite database connection?
It is good to separate out your data access from your user interface. That way you can change your user interface without changing your data access. It makes for a cleaner design. You don't have to do it, though.
Hi Tim, iI read the data from the database and use that data to calculate the main data. Then, I update the calculated data into the database again. The problem is that the 'database is locked'. I can't think of a solution. If you have good ideas, please tell me.
It sounds like you aren't closing out a transaction to SQLite before you are attempting a different transaction. Make sure you are closing your transactions right away (I'm using "using" statements to ensure they get closed right after the call).
You select "Copy if newer" for the db file. Does this mean that after adding a new column to a table using the DB Browser, all of the data in the debug db will be lost the next time you build the project, since the blank db will overwrite it? A solution could be to add columns directly to the debug db, but then you risk having mismatched db structures between your blank db and debug db?
Yes, it will overwrite your database in debug. However, since the database in debug is just for testing, that isn't necessarily bad. Now if you have a bunch of setup data in it for easier testing, that would be a pain. In that case, you will need to manually update your debug database or point to one that isn't copied every time you build.
Hey Tim, got a question, are you planning on doing a MySQL video? I was having a problem with a dotnet core app I was working on and at first I thought that my data source to MySQL was wrong but after trashing the program and reverting to SQLServer I found that I was having the same issue with it. Turned out to be a flaw in my Angular code
I am watching this in 2023 - is there a workaround to having to include that System.Data.Sqlite.Core dependency in your consuming project? I am on a dependency management kick and would like to break that one if possible. Regardless - thank you Tim again for saving me so much time.
Great video as usual. I have added a few extras and made a subwindow for the person part - somehow I cant get the data shown in my person window. It seems to save to the DB tho. Being new at c# my headaches are only minor, but they will prob grow. :D Thx again Tim - great stuff!
What are the advantages of using SQLite over SQL localDB? I guess they are all file based database and with sql localdb you could easily migrate to a full SQL very easily by just changing a connection string I believe. Why would one prefer SQLite over localdb? Thanks
Hi Tim, you know the saying you cannot teach an old dog new tricks? Well, you busted that one. You taught this old dog a new trick and it's just marvellous. Thanks man!!!!
Awesome! I’m glad it was helpful.
Tim's courses are by far the most clear and concise I've done. Having the code to download to play with is so useful. A great resource.
I appreciate the kind words.
Thank you for a great, direct and useful tutorial for SQLite in C#. I am new to SQLite and this video was a real example of a quality presentation with real-world scenarios of using C# with a file-based database system in a contained environment. Well done, sir.
Thank you for watching. Please check out the other videos on Tim's Channel.
By far and away the best C# material on youtube, thanks for all your help.
You are most welcome. Thanks for watching.
17:26 Relative connection string
19:11 - 21:50 Dependent packages
26:00 Get connection string in library project
29:47 Query list of PersonModel from db
31:50 Write a person to db
I added it to the description. Thanks so much.
@@IAmTimCorey Can you set up a pay method for AliPay? I believe there are many Chinese subscriber like me who what to enroll your course. Most chinese don't use credit cards.
Unfortunately, I don't have the ability to do that. Teachable (my host) only provides Stripe and PayPal.
Tim Corey, Thanks! I can't express how much I have learned from your videos.
I’m glad my content has been so helpful.
I had to learn a bit of java lately, forcing me to watch some different tutorials, and let me say this, you have achieved your goal. You do make learning c# easier.
I appreciate the kind words.
Great video! I'm happy you're back!
Thanks. I'm happy to be back.
0:00 - Intro
1:14 - Demo app overview (win form app)
4:30 - What is SQLite
5:09 - How to create and build SQLite Database: DB Browser for SQLite
11:17 - Database Structure
13:04 - Adding the Database to the project
15:26 - Adding the Connection string
18:15 - SQLite and Dapper NUGet packages
21:58 - Data access setup
28:17 - Retrieving data form DB: LoadPeople()
30:14 - Sending data to DB: SavePerson()
31:51 - Wiring up the Demo app
33:08 - Workings with the Database
36:18 - Summary and concluding remarks
Great job, thanks again
Love you, Tim!!! I cannot describe how happy I am to find this tutorial :DDD Thank you endlessly !
Be sure to check out the whole channel - th-cam.com/channels/-ptWR16ITQyYOglXyQmpzw.html. Use the search icon under the Subscribe button to search within the channel to find the training you need next.
This is the video I have been waiting for. Thanks Tim. I have a number of projects I get me teeth in to now.
Excellent!
Just need to decide witch one to start with lol
Your channel is a gold mine. Super awesome content.
I appreciate the kind words.
Glad to see you have pulled through. And thank you for another great video.
You are welcome.
thanks, Tim for all the videos and effort your providing. you are a legend, you are the best teacher ever. definitely, I will have a course with you one day.
I appreciate that!
Thank you for a great introduction to SQLite!
You're very welcome!
This is an incredible tutorial, even if it just covering the very basics.
i gotta admit, in itself SQLite is quite a powerful tool.
Thanks a lot, Tim!
You are most welcome. Thanks for watching.
i love the intro, iit explains EXACTLY what I am looking for, so in watching this, I went, yes... yees.. YES!!!
Great!
Boss ...you are just brilliant ......wooww...every topic explained very clearly.....u know what is missing in daily soap and u just bang on fish eye.....
Thank you!
Your tutorials are so clear and straight to the point! ❤
I am glad they are helpful.
It is a very good tutorial to learn to connect a database for quick use for your application
I am glad it was helpful.
Hello Corey, Thank you for the excellent tutorial
You are welcome.
I know this is sort of outside the scope but, If you want to distribute your application with some tables containing data, I prefer using EmbeddedResource as the compile action and using that to create the db file if it doesn't exist at the specified path. This allows you control when the database file is copied/written. I feel like this offers more control over the database file on deployment when users execute the program. You can offer the user features such and restarting from scratch you can disconnect from the database, delete the db file and replace it with the embedded resource version of the database. Like for example if the database somehow got corrupted.
Thanks for sharing!
I am going to use this tutorial in some personal tools! Thanks a lot, Tim!
Excellent!
I just needed this. Thanks for the video. There are a lot of resources out there but they are just messy.
Glad it was helpful!
Nice tutorial Tim, looking forward to the full course.
Great!
Thank you for the excellent guide, you are a great teacher
You are welcome.
Perfect / Simple and Useful even for experts
Thanks!
YES, I have been waiting for this!
Excellent!
Tim Corey is my .net god!
lol thanks.
A very comprehensive method Tim
Thanks!
Great video - looking forward to doing the full course
Great!
Tim - "Its not too much to ask a person to give me a first and last name". Maddona- "Am I a Joke to you?! Do I not get to play in your database?" :P J/k, this is amazing and I'm subscribing just because of how well laid out this is. I needed something to explain c# and sql lite but didn't want a 3 hour course, and I needed some basics on the sql lite part as well. You did a great job with this!
I'm glad it was helpful. And yes, people will always have an exception to the rule, which makes creating any type of validation hard.
Thanks. I am definitely buying your start to finish course.
Thank you!
Superb tutorial yet again! you never fail buddy :)
Thank you!
Thanks for the great course and general sharing knowledge
Thanks for growing your skills with Tim
Extremely clear explanation, great job!
Thank you!
Thanks for this tutorial Tim
You are welcome.
Thank you so much for this! You're an absolute lifesaver!
You are most welcome. Thanks for watching.
I like the video before watching 😊😊
I am glad you have such faith in me.
Tim Corey you saved my ass, love you
Great!
great tutorial!
샘 짱이에요 :) 쉽게 잘 가르쳐주시네요 from s.korea
Thank you!
Thank you. it is what i was looking for!
You are welcome.
Very good video. Exactly what I was looking for and the video already answered a lot of my questions.
Glad it was helpful!
Waw, this is the best explaining. It's incredible
Thank you!
Thank you so much sir.... Nice and easy tutorial.
You are welcome.
Thanks for the video Tim
You are welcome.
Thank you very much! very useful course.
You are welcome.
Tim, I agree the way of teaching is amazing with slow pace and injecting in viewers mind slowly and nicely.
But at time confusing may be because of the method you took up about SQL connections and accessing.
In fact I saw better methods in the net without confusion.
Thanks any way...
Well, if you know an easier way of doing it for you, that's great!
Pls. don't mind Tim.
Again and again I say your way of teaching is ultimate. That was the only video confusing a bit, rest all the best.
Thanks for informative video, Tim!
Thanks for watching
super work Tim Corey
Thanks!
Great video. Thanks.
Just to clear my understanding, SQLite is just meant for 1 user, you can't point 2 or more machines to the same SQLite database so they have same data like in full sql.
You technically can, but SQLite was designed for one user. Having multiple use it will increase the likelihood of collisions.
@@IAmTimCorey Thanks.
I think with sqlite you may even be limited on how many connections you can open to db. It is limited to single user.
Thanks a lot for the video and explanation man, was easy to understand and extremely helpful.
You are most welcome. Thanks for watching.
Thank you so much for this video Tim, I've been looking for a basic video like this for a good few days, the whole SQL localdb vs SQL Express vs SQLite was just far too confusing when I knew SQLite was what I needed, I just couldn't find a video to show a simple connection (ignore me (apart from the thanks bit) as these might just be words from a rambling programming student).
Glad it was helpful!
Thanks for the useful videos.. One useful suggestion is please zoom to the text in focus to reduce strain in eyes especially for mobile phone user
I do what I can but trying to scale it for mobile is almost impossible.
Thank you so much for posting this! New subscriber here!!
You are welcome.
You AMAZING Tim. Thank you
Thanks for trusting Tim
Great video tutorial! Thanks for that!
You are welcome.
Excellent video. Thank you
You are most welcome. Thanks for watching.
Thank you very much Tim!
You are welcome.
Thanks a lot for this video. Quite explanatory!!!
Glad it was helpful!
This helped me a lot, thank you
You are welcome.
Thank you for the video! Just FYI, in WinForms you would want to use a Binding List, not an observable collection.
Thanks!
Thanks man! Helped me alot.
You are welcome.
Gracias excelente Mister Tim.....
Thank you!
Super video thanks!
Glad you liked it!
good job beautiful video very easy to understand useful for beginner helpful for manipulate project include sqlite data for mono pc i like your job continue
Thank you.
Thanks for the video, it was powerful
You are welcome!
@IAmTimCorey: Fantastic tutorial! I've worked with SQLite on a mobile app via xamarin forms, but the process was VERY different. Thanks!
Thanks!
great video.
Thanks!
Great, Thank you so much.
You are welcome.
Thank you for the video.
You are welcome.
Great video. But I have a problem with sqllite. It does not handle storage to well. What I mean is that once a data is deleted. It does not use that space again. So the database can get bloated with empty space.
By far the best SQLite in C# example video I saw. The only problem I'm having now is in visual studio it runs fine (debug and release mode), but when I publish it I'm getting an 'unable to load dll 'sqlite.interop.dll'' error.
When you publish, make sure the SQLite interop dlls are going too. I believe they are in a sub-folder under Debug or Release and there are separate DLLs for 32- vs 64-bit.
@@IAmTimCorey I think this is my problem too. How do you "make sure" they are included in the publish?
In .Net Core 3.1 using Visual Studio 2019 Community Edition, you have to download a Nuget Package Called System.Configuration.ConfigurationManager in order to read the app.Config. See video clip at 24:53.
Yep, I was using the .NET Framework in this video. Thanks for sharing how to do it in .NET Core 3.1.
@@IAmTimCorey Thanks Tim for the video. Your samples are really amazing. My app is 100x better now incorporating your sample!
That was the just info I needed. Thank you!
Thank you for this
You are welcome.
Great course, Tim. I am a new subscriber and I have been learning more from your tutorials than I have on other learning platforms. I encountered an interesting issue with Dapper while coding your demo. It turns out that Dapper isn't a big fan of interfaces so when I tried to be "smart" and created a list of IPersonModel objects, the insert failed. I had to switch my type back to the actual type.
Yep, because Dapper is going to use an actual type to do work. It cannot take an interface because it doesn't know which type to use to do the actual work.
@iamtimcorey any chance of a WPF example? I can't work out where the connections strings etc go.
They go in the same place. WPF projects have an app.config file too. If you are referring to WPF Core projects, you would put the connection string in the appsettings.json file (examples of using connection strings with both of these types and more are in the TimCo Retail Manager series).
I was just thinking the same thing with .NET Core and figured it out with a bit of googling.
This works:
1. Add "System.Configuration.ConfigurationManager" NuGet-package (instead of reference)
- Major change
2. Create App.config with the connection string inside configuration (like in the video, but doesn't have any of the other groups) then set the file to "content" and "copy to output" (like the database file).
- Has to be created manually.
3. Rest works like in the video.
How can I use triggers in Sqlite and c#? Is that possible? I don't think so, because sqlite doesn’t work with stored procedured. How do I send values to my triggers without stored procedured?
Unfortunately, you cannot use Stored Procedures in SQLite. You don't send parameters to a Trigger. You automatically have access to inserted, updated and deleted rows when you're writing the trigger code..
@@stanscocom so i can't send dinamics values for the triggers?
@@signo18 No - Triggers are not really triggered by your code. They are triggered by the database when table data is changed. So, even in the SQLite Browser (where you can edit the data in the database), if you change the value of a column that has a trigger on it, the database will automatically execute the trigger immediately.
You could make an extra table for parameters, e.g. TrgParams, and in your table add a column called TrgParamID. Insert parameter in TrgParam table, get its id, and when updating your real table, also set value of TrgParamId column to the new id, e.g. 10. The trigger should fetch the id from the new record, search for the parameter in the TrgParams table, then work based on that.
Please, make video about dependency injection
It is coming.
cooool! you are the best
I love your tutorials, really easy to understand and follow. At the moment i'm struggling with creating and printing custom documents in c# (reports, receipts) . I tried RDLC but it feels kind of clunky . That would my suggestion for a future video.
Thanks for the suggestion.
very good.
Thank you.
You are the best ! ;D
Thank you.
I love the simplicity if SQLite, especially with WPF development.
I’m writing an app now that will allow the user to password protect specific records.
For the average user, they won’t know how to open the .Db file, but I can’t help but ask, HOW can I encrypt the SQLite database?
I’ve seen mentioned SQLite Cipher, but is that the best way to go when working w/WPF applications?
Any suggestions are definitely appreciated!
I also feel SQLite encryption would make a great follow up video to your other training on SQLite!
Thanks!
It is just password protection (which is probably all you need) but have you tried this: stackoverflow.com/a/17855620/733798
Gracias Mister Tim
De nada.
Hello Tim Corey. I was wondering if you could please explain why the Database file that we created and saved to the WinFormUI project folder is not written to, but instead another Db file is created in the WinFormUI\bin\Debug directory that is written to? Also, if you have a link to some literature that explains why the Db in the Debug directory is used that would be helpful too. Thanks !!!
The connection string tells the application where the database is. Since the connection string did not specify a path, it assumes a relative path (relative to the executable running the command that uses the connection string). That's why we have to copy the database into the debug folder. Also, by using a copy of the database instead of the one we include with our project, we won't have sample data in the database we give to customers (unless we want it in there).
The reason you need to reference the sql lib also in WinFormUI, is a visual studio bug, that sticks around.
I usually use typeof on a class from sqlcore lib in the DemoLibrary, so visual studio see's you actually using it, and doesn't get rid of the .dll, and it doesn't need to be referenced in the WinFormUI.
Thanks for sharing.
very very nice thanks so much
Thanks for the support! Tim appreciates it.
Hi Tim, i have a question. What is the purpose of the DemoLibrary project? Is that needed or can i have my models and NUGet packages in the UI project?
It keeps a separation between your business logic and data access from your user interface. Putting everything in your UI locks you in by tightly coupling your application together. By using a class library, we can disconnect this and make it easier to upgrade parts of our application without upgrading the entire thing.
Hello Tim, I'm happy you're back ! I got a question, are you planning on doing a NHibernate 4+ course/tutorial?
Probably not. It isn't something I use.
23:00. I get the error "type or namespace "Personmodel" could not be found". Please help and thanks in advance.
You probably did not mark your PersonModel class as public. Either that or you mistyped it as "Personmodel" when you meant "PersonModel".
hey tim bro , how can we store dates and time etc
There are options, but the easiest one in my opinion is to use a text field. You could use an integer and calculate seconds from 1970 among other options, but those options aren't human-readable when scanning database columns. I prefer just using text and converting it back to DateTime.
@@IAmTimCorey So If We Have A DateTimePicker named as DTP this means we can define string theDate = DTP.Value.ToString("yyyy-MM-dd")
OR Something Like This and Then We Should Store THis String onto the DB
Hello, I do not understand why you have to create 2 projects (DemoLibrary and WinFormUI) because, it makes you add twice the nuGet packages? Thank you :)
I almost always create a class library because your code should not be directly tied to your user interface. Otherwise it is rigid and hard to update.
Hello, thank you for your explanation. This is similar to the MVC, I understand better;) did a series of video to explain precisely how organized his project? I'm waiting for that, the creation of file to "tidy up" these classes, etc., thank you!
I am unsure why you need a second project (DemoLibrary) to do this SQLite thing. Could you do all that within one project or do you need to have two projects to accomplish a SQLite database connection?
It is good to separate out your data access from your user interface. That way you can change your user interface without changing your data access. It makes for a cleaner design. You don't have to do it, though.
Hi Tim, iI read the data from the database and use that data to calculate the main data. Then, I update the calculated data into the database again.
The problem is that the 'database is locked'. I can't think of a solution.
If you have good ideas, please tell me.
It sounds like you aren't closing out a transaction to SQLite before you are attempting a different transaction. Make sure you are closing your transactions right away (I'm using "using" statements to ensure they get closed right after the call).
You select "Copy if newer" for the db file. Does this mean that after adding a new column to a table using the DB Browser, all of the data in the debug db will be lost the next time you build the project, since the blank db will overwrite it?
A solution could be to add columns directly to the debug db, but then you risk having mismatched db structures between your blank db and debug db?
Yes, it will overwrite your database in debug. However, since the database in debug is just for testing, that isn't necessarily bad. Now if you have a bunch of setup data in it for easier testing, that would be a pain. In that case, you will need to manually update your debug database or point to one that isn't copied every time you build.
@@IAmTimCorey Awesome, thank you, Tim.
thank you! I like you accent btw
Thanks!
Hey Tim, got a question, are you planning on doing a MySQL video? I was having a problem with a dotnet core app I was working on and at first I thought that my data source to MySQL was wrong but after trashing the program and reverting to SQLServer I found that I was having the same issue with it. Turned out to be a flaw in my Angular code
MySQL is also on the list of database topics.
I am watching this in 2023 - is there a workaround to having to include that System.Data.Sqlite.Core dependency in your consuming project? I am on a dependency management kick and would like to break that one if possible. Regardless - thank you Tim again for saving me so much time.
Yes, if you have all of your data access code fully in the class library then the UI doesn't need to know about it.
Great video as usual.
I have added a few extras and made a subwindow for the person part - somehow I cant get the data shown in my person window. It seems to save to the DB tho.
Being new at c# my headaches are only minor, but they will prob grow. :D
Thx again Tim - great stuff!
Glad you are working through the issues. I have a video on debugging that might help out. :-)
I will go have a look- Thx again.
Everything works now. DB seems to be updating and responsive. I love you man! :)
What are the advantages of using SQLite over SQL localDB? I guess they are all file based database and with sql localdb you could easily migrate to a full SQL very easily by just changing a connection string I believe. Why would one prefer SQLite over localdb?
Thanks
SQLite is designed to be portable with just a dll and the database file.
Hi
Thannks for your video.
Do you recommend a way to trace/debug queries on SQLite in C#?
No, sorry. I don't think I've ever had the need.
@@IAmTimCorey How can you make sure to have right queries all the time? I have a syntax error but I can't figure it out how