DotNet MAUI Sqlite Tutorial - .Net MAUI Sqlite CRUD Operations

Поделиться
HTML-код
  • Опубликовано: 31 дек 2024

Комментарии • 128

  • @CodingDroplets
    @CodingDroplets  Год назад

    ⭐ Join Us on Patreon: www.patreon.com/CodingDroplets
    MAUI Tutorial Series: ruclips.net/video/O3-jFuXqASE/видео.html&pp=sAQB

  • @AfSA-y4d
    @AfSA-y4d 5 дней назад +5

    Hello can I ask where is that database file specificaly located, if I want to look at it on some DataBase browser?

  • @SimpleTTech
    @SimpleTTech 8 месяцев назад +6

    OMG, you literally made the 1 hour teacher explanation in just 9 minutes, thanks dude!

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад +2

      I'm glad you found the tutorial helpful!

    • @SimpleTTech
      @SimpleTTech 8 месяцев назад +1

      @@CodingDroplets 🙌🏽

  • @dikkebmw595
    @dikkebmw595 Год назад +5

    Thank you for this very user-friendly series!

    • @CodingDroplets
      @CodingDroplets  Год назад

      You're very welcome! I'm glad you found the series user-friendly and helpful.

  • @ismailvfx31
    @ismailvfx31 Месяц назад +1

    Best Channel For .net tech ♥

    • @CodingDroplets
      @CodingDroplets  29 дней назад

      Thank you so much for your support! 😊 Your kind words mean a lot. Stay tuned for more .NET content, and feel free to share any topics you'd like me to cover. 🚀♥

  • @jorgejorge8878
    @jorgejorge8878 Год назад +5

    This video made me subscribe. You´re a treasure.

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      Thank you so much for the incredibly kind words!

  • @maciejkolacinski8958
    @maciejkolacinski8958 Год назад +7

    Great tutorial, very easy to follow 😊 the only thing is the dependency injection was very brief so i think a video on that would be useful or even a video on design patterns in C#

    • @CodingDroplets
      @CodingDroplets  Год назад +3

      Thank you for your feedback! I'm glad you found the tutorial helpful. Your suggestion about creating a more in-depth video on dependency injection is fantastic, and I appreciate your input. I'll definitely consider creating a dedicated tutorial to delve deeper into dependency injection in the context of .NET MAUI.
      Additionally, a video covering design patterns in C# is an excellent idea! It's a broad but crucial topic, and I'll work on creating content that provides a clear understanding of various design patterns.

    • @trustingod0
      @trustingod0 Год назад +1

      @@CodingDroplets Great Video and I would like to see a deep dive into MVVM design pattern with .Net Maui. Thanks !!!

  • @sbjakhotya
    @sbjakhotya 10 месяцев назад +3

    At 3:10 added method CreateTableAsync for Customer in Constructor, It will execute on every run of application so won't it Create new table every time the app is opened?

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад +3

      The CreateTableAsync method checks if the table already exists in the database before attempting to create it.
      So, while the method call is in the constructor, the table creation logic will only execute if the table doesn't already exist in the database. If the table does exist, it won't create a new one, ensuring that your data remains intact across multiple runs of the application.

  • @oscaralexanderayalagarcia1847
    @oscaralexanderayalagarcia1847 Год назад +1

    Muchas gracias!! me has salvado de un proyecto de la universidad, tenga su like buen hombre

  • @someoneofpeople
    @someoneofpeople Год назад +7

    Thanks a lot we highly appreciate your amazing videos.
    If you could do another video for an already existing SQLite db with entity framework that would be very beneficial for a lot of developers.

    • @rntechnology8102
      @rntechnology8102 Год назад +2

      This is my need also please

    • @CodingDroplets
      @CodingDroplets  Год назад +5

      Thank you for your kind words! I'm delighted to hear that you find the videos helpful.
      Certainly, creating a tutorial for using an existing SQLite database with Entity Framework in .NET MAUI sounds like a great idea. I'll add it to the list of upcoming tutorials.

    • @CodingDroplets
      @CodingDroplets  Год назад +2

      @rmtechnology8102 Will do a video soon.

    • @dikkebmw595
      @dikkebmw595 Год назад +2

      Agree! Hoping to see a Entity Framework video soon.

    • @曼巴-z1t
      @曼巴-z1t 9 месяцев назад

      @@dikkebmw595 I don't think it's necessary,these operation table statements are already very convenient

  • @almanzalj2066
    @almanzalj2066 10 месяцев назад +3

    Thanks for the video. How to insert into an image field in the Sqlite database?

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад +2

      In SQLite, you can insert an image into a field by converting the image into a byte array and then inserting that byte array into a BLOB (Binary Large Object) field in the database.

  • @meetvishavadia9122
    @meetvishavadia9122 9 месяцев назад +1

    Excellent tutorial! This channel simplifies complex topics wonderfully. Could you please create a video explaining how to use the RefreshView feature for pull-to-refresh functionality? Specifically, I'd like to learn how to implement pull-to-refresh to refresh a ListView inside a RefreshView that fetches data from an SQLite Database.

    • @CodingDroplets
      @CodingDroplets  9 месяцев назад

      Thank you for your kind words and for watching the tutorial! I'm glad you found it helpful. I'll definitely consider creating a video tutorial on this, specifically covering how to refresh a ListView populated with data from an SQLite Database.

  • @sbjakhotya
    @sbjakhotya 10 месяцев назад +2

    LocalDbService class sounds like a Common Service for Entire Application, however it serves for 1 table only, should we add all table service code to single file or create separate classes for each table like LocalCustomerService, LocalProductService, LocalInvoiceService and so on?

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад +2

      Great observation! While the LocalDbService class may initially sound like a common service for the entire application, it's indeed focused on managing operations for a single table.
      When organizing your application's services, it's generally a good practice to follow the Single Responsibility Principle (SRP) and separate concerns. Creating separate classes for each table can help keep your codebase clean, modular, and easier to maintain.
      Each service would then be responsible for managing operations related to its respective table, leading to better organization and maintainability. Additionally, this approach allows for easier scalability and extensibility as your application grows.

  • @曼巴-z1t
    @曼巴-z1t 9 месяцев назад +1

    Great, I followed the video to achieve the above functions。

  • @DeshiExplorer
    @DeshiExplorer Год назад +1

    Thank you so much for the video, I have one question, Lets say we have the app in the app store, now in the next release we need to add new one field in the Customer entity, how to update local database when user update the app?

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      I'm glad you found the video helpful! Updating the local database when there are changes to the entity structure is a common scenario.
      Keep track of the database version in your app. When you make changes to the entity structure, increment the version number. In your app code, check the current database version against the expected version. If they differ, perform a database upgrade. Write migration scripts to update the existing database schema to the new structure. These scripts should handle tasks like adding a new field to the Customer entity.

  • @KleenAir-l7i
    @KleenAir-l7i 4 месяца назад +1

    I'm Wondering, How would you go about setting an OrderBy statement in one on the Data Service Methods

    • @CodingDroplets
      @CodingDroplets  4 месяца назад +1

      You can easily add an OrderBy statement in your data service method when querying your SQLite database. Below is an example.
      *await _connection.Table().OrderBy(x => x.CustomerName).ToListAsync();*

  • @artaxerxes142
    @artaxerxes142 Месяц назад +1

    there's not much encapsulation, why did you not use a ViewModel class as intermediary between your customer model and mainpage?
    also , why did you not use observable collections? that would've been really convenient.

    • @CodingDroplets
      @CodingDroplets  Месяц назад

      Great questions! 😊 I focused on demonstrating the basics of SQLite in this video, so I kept it simple. However, I do have another video that covers the MVVM pattern in detail, which uses ViewModel classes and ObservableCollections to better encapsulate data and improve UI updates. You can check it out here: ruclips.net/video/B-5e0PJtSDs/видео.html

  • @YewMengTan
    @YewMengTan Год назад +1

    Hello, I would like to ask why we need to set the value of the _editCustomerId variable to zero, after successfully updating the Customer object ???

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      Great question! Setting the _editCustomerId variable to zero after a successful update in the .NET MAUI Local Database tutorial serves a specific purpose.
      In the tutorial, a single "Save" button is used for both inserting a new customer and updating an existing one. After successfully updating a customer, setting _editCustomerId to zero ensures that the application is ready to insert a new customer the next time the "Save" button is clicked.
      By resetting the _editCustomerId to zero, the logic in the code understands that the user intends to perform an insertion instead of an update. This helps manage the state of the application and ensures that after completing the editing process, the user can seamlessly add a new customer.

  • @paudricsmith619
    @paudricsmith619 6 месяцев назад +1

    how do you view the database? i have tried to find the db file on the vs emulator but no file is there.

    • @CodingDroplets
      @CodingDroplets  6 месяцев назад

      To view the SQLite database in your .NET MAUI application, you can try using adb (Android Debug Bridge) to pull the database file from the emulator and then use a SQLite viewer application. Use adb to locate and pull the database file, and then open it with a SQLite viewer like DB Browser for SQLite. I haven't tried this method yet, but it should help you get started.

  • @neomachine8773
    @neomachine8773 7 месяцев назад +1

    Thanks from Colombia you are the boss

  • @trustingod0
    @trustingod0 Год назад +1

    Thank you Sir for answering my question about a similar tutorial I followed about using SQLite class library but the method to return all records in a table didn’t work.

    • @CodingDroplets
      @CodingDroplets  Год назад

      You're very welcome! I'm glad I could help address your question and provide assistance with the SQLite tutorial.

  • @etcast1559
    @etcast1559 5 месяцев назад +1

    Tried; but ran into exception:
    [monodroid-assembly] open_from_bundles: failed to load assembly SQLitePCLRaw.core.dll.

    • @CodingDroplets
      @CodingDroplets  5 месяцев назад

      The error you mentioned, [monodroid-assembly] open_from_bundles: failed to load assembly SQLitePCLRaw.core.dll, typically occurs when there's an issue with the assembly references. Make sure you've added all the necessary NuGet packages for SQLite, especially sqlite-net-pcl and SqlitePclRaw.bundle_green. If the issue persists, try cleaning and rebuilding your solution.

  • @miguelcahuas
    @miguelcahuas 3 месяца назад +1

    Thank you! Please share crud for master/detail tables

    • @CodingDroplets
      @CodingDroplets  3 месяца назад

      You're welcome! 😊 I'm glad you found the video helpful. I’ll definitely plan to cover CRUD operations for master/detail tables in a future video. Thanks for the suggestion.

  • @michaelchristensen8350
    @michaelchristensen8350 Год назад +1

    Wow this tutorial is very good. Could you please make another video where you show how to sync the Local SQLite DB to a online backend.(Maybe it could be part 2 of this video. So in that way the data is synced when the device is online)

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      Thank you for your positive feedback! I'm delighted to hear that you found the tutorial helpful.
      I'll certainly consider creating a part 2 of this video that focuses on syncing data when the device is online. It's a valuable topic, and I'll make sure to cover the process in a clear and comprehensive manner.

    • @michaelchristensen8350
      @michaelchristensen8350 Год назад

      @@CodingDroplets great I will be sure to check it out when it's ready.

  • @mikeyim9597
    @mikeyim9597 2 месяца назад

    You have the best Maui tutorial. Thank you so much. Can you do a tutorial for MySQL CRUD Operation?

    • @CodingDroplets
      @CodingDroplets  2 месяца назад

      Thank you so much for the kind words! 😊 I'm glad you found the MAUI tutorial helpful. I've actually covered MySQL CRUD operations as part of my microservices tutorial series. You can check it out here: ruclips.net/video/b1BSu0Wb2Rw/видео.html

    • @mikeyim9597
      @mikeyim9597 Месяц назад

      @@CodingDroplets Thank you for the link. I was hoping for the actual .Net Maui project. I'm unsure where to implement the CRUD operations when using the MVVM. Should I create a separate "service" folder and create a class to handle the CRUD operation or do it from the ViewModel?

  • @anandshindey
    @anandshindey 5 месяцев назад +1

    Excellent Video, it helped me. I do have a question. How do I do a rollback and commit? begin trans and end trans?. Also is there as guide for sqlite for .net maui ?

    • @CodingDroplets
      @CodingDroplets  5 месяцев назад

      Thank you! Glad to know the video helped. For rollback and commit operations, you can use the RunInTransactionAsync method provided by the SQLite library. You can find more details in the official guide here:
      github.com/praeclarum/sqlite-net/wiki/Transactions

    • @anandshindey
      @anandshindey 5 месяцев назад +1

      @@CodingDroplets thanks.

    • @CodingDroplets
      @CodingDroplets  5 месяцев назад

      Welcome

  • @trustingod0
    @trustingod0 Год назад +1

    How would you recommend I check if database has already been created?

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      Thank you for your question! In the .NET MAUI SQLite tutorial, the code snippet _connection.CreateTableAsync(); is used to create a table. It's important to note that this method will only create the table if it doesn't exist; otherwise, it will do nothing.

  • @nicolassuarez2933
    @nicolassuarez2933 3 месяца назад +1

    Outstanding!

    • @CodingDroplets
      @CodingDroplets  3 месяца назад

      Thank you so much! I'm glad you enjoyed the tutorial. 😊

    • @nicolassuarez2933
      @nicolassuarez2933 3 месяца назад

      @@CodingDroplets I am looking to add a simple register, login, logout to Sqlite, any tip? Thanks

  • @RidvanGER
    @RidvanGER 11 месяцев назад +1

    Thank you very much, would you also do one with EF with sqllite?

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      You're welcome, and thank you for your suggestion! I'm glad you found the tutorial helpful. I'll definitely consider creating a tutorial on that.

  • @hananehanane4881
    @hananehanane4881 Год назад

    please how to have handle on cancel button on picker ?

  • @trustingod0
    @trustingod0 Год назад +1

    What if I want to have Crud with different tables in a Shell Application ?

    • @CodingDroplets
      @CodingDroplets  Год назад +1

      Will try to include that topic in an upcoming video

    • @trustingod0
      @trustingod0 Год назад +1

      @@CodingDroplets Thanks Greatly Appreciate it and I look forward to donating to your channel

  • @MinhQuanCt3
    @MinhQuanCt3 5 месяцев назад

    very helpful for me, thank so much (from vietnam)

    • @CodingDroplets
      @CodingDroplets  5 месяцев назад

      Thank you for your comment! Glad to hear that.

  • @muralid2867
    @muralid2867 Год назад +1

    Thank you, sir, for this video. I have been eagerly awaiting it. I am currently developing a desktop application and considering whether to use SQLite database or another option. If an alternative is preferable, could you suggest the best database to implement? Additionally, I am using .NET MAUI and .NET 7, and I want to convert the application to an executable (exe) file to provide to the client. The condition is that there should be no additional files, such as images or fonts, included-only the executable and supported files.

    • @CodingDroplets
      @CodingDroplets  Год назад

      I'm glad you found the video helpful! For a desktop application developed with .NET MAUI and .NET 7, using SQLite as the local database is a reasonable choice, especially if you need a lightweight, file-based database solution.
      When it comes to converting your application into a single executable (exe) file without additional files like images or fonts, you might want to consider using a technology like "Single-file Publish" provided by .NET.

    • @muralid2867
      @muralid2867 Год назад

      @@CodingDroplets Thanks For Reply Sir , I am working on a POS software for a restaurant and bar. I need to print bills for both the restaurant and the bar. How should I design the print functionality? I also have a separate settings page where users can choose the printer and paper size.

    • @CodingDroplets
      @CodingDroplets  Год назад

      Please Check: github.com/dotnet/maui/issues/9931

  • @MichaelPradeep-oc2bs
    @MichaelPradeep-oc2bs 9 месяцев назад

    i install sqlite in local , how to connect with that database with dotnet maui?

  • @Fran-nk1qq
    @Fran-nk1qq 8 месяцев назад +1

    First of all, ty so much for your videos, they are so informative . I'm having a problem with SQLite, it works for me on Windows but not on Android, the database can't be created and it doesn't show me the data, I've tried to change the path folder and I can't get it works, some idea?

    • @Fran-nk1qq
      @Fran-nk1qq 8 месяцев назад +1

      I just saw you were using .Net 7, i've tried to use .net 7 for my app and it works, it should be some bug of the new version, if you know the way to make it work at net 8 let me know pls

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад

      Thank you for your kind words and for sharing your experience! I'm glad to hear that the tutorial was helpful for you. I appreciate you bringing this to my attention, and I'll investigate further to see if there are any updates or workarounds to resolve this issue with .NET 8. Once I have more information, I'll be sure to update the tutorial accordingly.

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад +1

      I tested with .Net 8 and everything is working perfectly. Just implemented in the same way. There are no changes at all. Please let me know the error message what you are receiving. It seems the issue you are facing is something else.

    • @Fran-nk1qq
      @Fran-nk1qq 8 месяцев назад

      ​@@CodingDroplets I fixed my error using other NuGet Packages. Im currently using Microsoft.Data.Sqlite and all going fine.
      The error was something related with the file of database cant be reached, but the file was never created at Android. The weird thing is that it worked for me at .Net 7 and Windows App, but it didn't at .Net 8.
      Tysm for your answer and your time. 🫡

  • @forsandykurniawandavid
    @forsandykurniawandavid 11 месяцев назад +1

    what folder you put sqlite db

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      In the demo project, the SQLite database file ("demo_local_db.db3") is placed in the AppDataDirectory. This is a common practice for storing application-specific data in a cross-platform manner.

  • @liemnguyen3088
    @liemnguyen3088 6 месяцев назад +1

    How about multi tables in database?

    • @CodingDroplets
      @CodingDroplets  6 месяцев назад

      Thank you for your comment! In the tutorial, I demonstrated using only one table for simplicity. However, you can include multiple tables in the same way. Just define additional models for each table and create them using the same approach.

  • @mix_gamer9021
    @mix_gamer9021 11 месяцев назад +1

    If I exit the application and load back in will it display all the customers that i have entered or will it delete them?

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      The implementation focuses on local storage using SQLite. When you exit the application and load it back in, the data should persist unless you explicitly delete it.
      If the app is uninstalled and then re-installed, the SQLite database, along with the data it contains, will typically be removed. This is because the uninstallation process usually includes the removal of the app's data and files, including the SQLite database file.

    • @mix_gamer9021
      @mix_gamer9021 11 месяцев назад +1

      @@CodingDroplets thanks, but i have one more question. Do i need to implement mvvm always or can i just use clicked events?

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      While using MVVM architecture is a recommended practice for building maintainable and testable applications, it's not strictly mandatory. The decision to use MVVM or rely on clicked events depends on the complexity of your application, your preferences, and your development goals.
      Using clicked events directly in the code-behind can be simpler for small applications or quick prototypes. However, as your application grows, MVVM can offer benefits such as separation of concerns, easier testing, and improved maintainability.

  • @rahulguleria4169
    @rahulguleria4169 Год назад +1

    Hello sir,
    How we can do offline sync in maui using sqlite

    • @CodingDroplets
      @CodingDroplets  Год назад

      You need to develop synchronization logic to periodically check for a network connection and sync the local SQLite database with a remote one using APIs. Use background tasks or services for seamless synchronization without disrupting the user experience.

  • @MSNarayan-er9xz
    @MSNarayan-er9xz 11 месяцев назад +1

    sir will you make one video on Mvvm pattern.

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      Absolutely! I've already created a tutorial on the MVVM pattern and Data Binding in a .NET MAUI application. You can check it out here: ruclips.net/video/B-5e0PJtSDs/видео.html

    • @MSNarayan-er9xz
      @MSNarayan-er9xz 11 месяцев назад +1

      @@CodingDroplets thanks a lot for your message sir.

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад

      You are most welcome!

  • @HelloPadam
    @HelloPadam 11 месяцев назад +1

    How to use db from web server

    • @CodingDroplets
      @CodingDroplets  11 месяцев назад +1

      If you want to use a database from a web server in your .NET MAUI application, you would typically implement API CRUD operations to interact with the server-side database.
      You can check it out here: ruclips.net/video/p3wOPX1Zoaw/видео.html

  • @hyperdrivekpm221
    @hyperdrivekpm221 10 месяцев назад +1

    I keep getting system. NullReferenceExpection 'object reference not set to an instance of an object' when trying the insert method

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад

      I'd recommend double-checking your SQLite connection to ensure it's properly initialized and that the object you're attempting to insert isn't null.

  • @sbjakhotya
    @sbjakhotya 10 месяцев назад

    Please add Invoice making tutorial of type Master - Details all with Database

  • @muralid2867
    @muralid2867 Год назад +1

    Sir Can Make video of how to localization in .net maui

    • @CodingDroplets
      @CodingDroplets  Год назад

      Certainly! I appreciate your suggestion. Creating a video on localization in .NET MAUI is a great idea, and I'll certainly consider it for a future tutorial.

  • @ИванБармин-ю1т
    @ИванБармин-ю1т 10 месяцев назад +1

    good short lesson, it’s a pity that, like all the others, the example uses a relational database, but not with relational or hierarchical data

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад

      Thank you for your feedback! I'm glad you found the lesson helpful. I understand your point about using a relational database in the example. While this tutorial focused on SQLite, which is relational, I'll definitely consider covering topics related to hierarchical data in future tutorials.

  • @sbjakhotya
    @sbjakhotya 10 месяцев назад +1

    this Sqlite Tutorial has to cover first before Web API for CRUD in the Play List (step by step implementation) Web API was so weird and dreadful

    • @CodingDroplets
      @CodingDroplets  10 месяцев назад

      Thank you for your feedback! I apologize if the previous tutorial on Web API felt challenging. I'll do my best to ensure that future tutorials are more straightforward and easier to follow.

  • @aweaawe
    @aweaawe 8 месяцев назад +4

    this code doesnt work and u paste it from somewhere idc but dislike

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад

      I'm sorry to hear that you had trouble with the code in the tutorial. Your feedback is valuable, and I apologize for any inconvenience caused.
      To address your concerns, I recommend reviewing the source code available at this link (github.com/codingdroplets/MauiSqliteDemo) for a clearer understanding of the implementation.

  • @aweaawe
    @aweaawe 8 месяцев назад +1

    ur code doesnt work, the code is unreadable and u writing too fast like u paste from somewhere code, dislike

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад

      I'm sorry to hear that you had trouble with the code in the tutorial. Your feedback is valuable, and I apologize for any inconvenience caused.
      To address your concerns, I recommend reviewing the source code available at this link (github.com/codingdroplets/MauiSqliteDemo) for a clearer understanding of the implementation.

  • @JoeRomano-s8g
    @JoeRomano-s8g 5 месяцев назад +1

    How do you manage database migration?

    • @CodingDroplets
      @CodingDroplets  5 месяцев назад

      With sqlite-net-pcl in a .NET MAUI project, table creation will occur automatically if no table exists. However, if you need to change the structure of a table, like removing or adding columns, you can implement database versioning. When your application starts, you can check the database version and apply the necessary changes based on the version. This way, you can manage the migration process smoothly.

  • @ahmed-he6hl
    @ahmed-he6hl 8 месяцев назад +1

    i write all code but i have error in
    return await _connection.Table().Where(x => x.Id == id).FirstOrDefaultAsync();
    the error Severity Code Description
    Error CS0029 Cannot implicitly convert type 'SqlTest.Customer' to 'System.Collections.Generic.List'

    • @CodingDroplets
      @CodingDroplets  8 месяцев назад +1

      It seems like you're encountering a type conversion error in your code. The error message indicates that the method is expecting to return a single Customer object, but you're trying to assign it to a variable of type List.