C# Tutorial - How to Connect and Use Local Database in Visual Studio 2019 | FoxLearn

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 มิ.ย. 2024
  • How to Connect and Use Local Database in Visual Studio 2019 step by step create sql local database
    Website: foxlearn.com
    Through this tutorial you will learn:
    create local database in visual studio 2019, then connect and use local sql database in visual studio 2019 include operations
    insert update delete in c#.net
    insert update delete and view data from database in c#.net
    datagridview to database update
    datagridview to database insert
    insert data into database using c#
    how to create sql server database in visual studio 2019
    how to connect sql server with visual studio 2019

ความคิดเห็น • 139

  • @chrysanthemum9484
    @chrysanthemum9484 3 ปีที่แล้ว +7

    Good Lord thank you. This answered like a third of the questions I had about the use of database in VS2019.

  • @xyrusdos3008
    @xyrusdos3008 3 ปีที่แล้ว

    THANK U SO MUCH YOU SAVED ME FOR GETTING A 75 GRADE!!

  • @mohamadrezaghadami1238
    @mohamadrezaghadami1238 3 ปีที่แล้ว +1

    the most helpful one ! thank you so much

  • @karlatwork688
    @karlatwork688 4 ปีที่แล้ว +1

    Another excellent video. Thanks and keep up the quality work.

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      Thank you so much !

  • @mypettaco
    @mypettaco 4 ปีที่แล้ว +1

    Hello. First, thanks for the video it saved me a lot of work/research.
    I'm having a separate issue that I think you might be able to help me with. I have two solutions, one similar to this that edits a database (for testing purposes), and another which is reading the database and doing stuff with the data.
    What I want to do is deploy these two projects together, so if anyone clones the repo they have full functionality. For my other project, I have manually configured the connection string to read the database from the executing folder and that solution copies the database to the executing folder. So I maintain a "virgin" copy of the db in the original location, and then edit the one in the runtime folder.
    I've included the same db in the db editing program. However, when I compile it, it connects to the "virgin" db as I can see that is where the connection string is pointing. I've played around with the connection string and keep getting an error "An attempt to attach an auto-named database for file ... failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
    I'm hoping you can tell me how to get it to point to the db in the runtime directory, rather than the original one.
    Thanks!

  • @Predo1064
    @Predo1064 4 ปีที่แล้ว +2

    Great video, thank you. I do have a problem though and would be very grateful for any help. When I run the data configuration wizard, after I have selected the table and click finish I keep getting an error. Could not find file dbo.Purchase, Purchase being the table name.

  • @borisndong6747
    @borisndong6747 3 ปีที่แล้ว +2

    He made it so simple and easy to understand ...

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      Thank you !

  • @matthewalexander565
    @matthewalexander565 ปีที่แล้ว

    God bless this tutor so much abegggg. This was sooo sooo helpful

  • @LeeKobe1
    @LeeKobe1 10 หลายเดือนก่อน +1

    Excellent tutorial! Many of us who followed these steps, and then ran the form, could not save the data inspite of clicking on the Save icon. Thoughts? I do have one other question...I have included a line in the table with 'image' selected as type of input. I'd like to upload an image on that line and into the form/app. Can you point me in the right direction? Thank you! (Bonus question: during the video, just after dragging the dataset to the form, it shows a quick move (step) in making the ID field disappear. It was so quick that even after rewinding several times, I couldn't catch the step. Can anyone shed some light on that?) Thanks.

  • @dimplekhurd0126
    @dimplekhurd0126 7 หลายเดือนก่อน

    Last min revision...Thanks a lot mam

  • @arthansen9297
    @arthansen9297 3 ปีที่แล้ว

    Incredibly useful - thank you.

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      Glad it was helpful! thank you !

  • @jimmyjobindi2128
    @jimmyjobindi2128 3 ปีที่แล้ว

    Excellent video. Thanks a ton.

  • @nathancrawley5212
    @nathancrawley5212 3 ปีที่แล้ว

    oh my gosh I needed this soo much

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      Thank you !

  • @kentabillon9951
    @kentabillon9951 4 ปีที่แล้ว +3

    This error shows when I try to save an item
    Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

  • @ybmprod4141
    @ybmprod4141 29 วันที่ผ่านมา

    It's fast
    But one of best Tut so far
    Thank U❤️

  • @utsavgohel9485
    @utsavgohel9485 2 ปีที่แล้ว

    thanku brother
    in this video i have cleared my database doutss

  • @cuadraramonvincent8043
    @cuadraramonvincent8043 3 ปีที่แล้ว

    do you have this for 2012 version of visual studio

  • @spiritretro3571
    @spiritretro3571 2 หลายเดือนก่อน

    i have an issue: i created a setup project to "install"the program (changed to release mdoe), and when i launch the installed program it says it either cannot connect to the db or a db with the same name already exists, whats going on?

  • @AKMROBLEH
    @AKMROBLEH 7 หลายเดือนก่อน +3

    Excellent tutorial! Many of us who followed these steps, and then ran the form, could not save the data inspite of clicking on the Save icon. Thoughts? I do have one other question...I have included a line in the table with 'image' selected as type of input. I'd like to upload an image on that line and into the form/app. Can you point me in the right direction? Thank you! (Bonus

  • @hansen_docked_in
    @hansen_docked_in 4 ปีที่แล้ว +3

    Hi! Great video. However I have one question: I followed your steps but my first input is not shown. Second row is fine and so on (so ID 2 is in row2/first row beneath header row). Any idea why? And how can I save the data to the table after closing the (compiled) program and also load data when opening it?

    • @YoungvLondon
      @YoungvLondon 4 ปีที่แล้ว +3

      I'm having the same issue. Seems no matter what data is in the fields, that first entry returns everything but the index as null values.

    • @hazielv.kapustin6138
      @hazielv.kapustin6138 2 ปีที่แล้ว

      Did you solve it? :c

    • @Jenil_Ramani
      @Jenil_Ramani 2 ปีที่แล้ว

      Click on save button when you run.

    • @osanbrazil999
      @osanbrazil999 ปีที่แล้ว +1

      Because you are running the program on the original folder, the data in the debug folder is deleted when u run (compile) the app again. Just copy the contents of the debug folder to another folder, e.g. "c:\myapps" and the table data will not be lost after you click on save button. When u run the program again, they'll be there.

    • @LeeKobe1
      @LeeKobe1 10 หลายเดือนก่อน

      @@osanbrazil999 Thanks. Many of us who followed these steps, and then ran the form, could not save the data inspite of clicking on the Save icon. I'll give your suggestion a try. I do have one other question...I have included line in the table with 'image' selected as type of input. I'd like to upload an image on that line and into the form/app. Can you point me in the right direction? Thank you!

  • @incognito5580
    @incognito5580 ปีที่แล้ว

    is it possible to migrate ms access database to the cloud and still be able to connect using c#?

  • @ehsanabbasi9405
    @ehsanabbasi9405 2 ปีที่แล้ว +2

    hello !
    I've created a database project like this.
    It works well on my computer but when I move debuged folder on another computer it doesn't work well.
    What Prerequisites needed to be install on that computer to run sql base projects.
    Thank you

    • @davidcerino1145
      @davidcerino1145 ปีที่แล้ว

      I don't know if you got an answer for this already, but I think you might need to make an installer, and then install that on the other machine to work. I just happen to see that on another video right before this one called "Build & Deploy C# Application And run it on any machine"

    • @black_sauce2478
      @black_sauce2478 ปีที่แล้ว

      This is not a Local Database, this database requires SQL server service. So you still need to install SQL server.

  • @Areeven
    @Areeven 6 หลายเดือนก่อน

    Awesome! Easy to follow =D

  • @bengali.318
    @bengali.318 11 วันที่ผ่านมา

    hey , i dont have the add new, cancel, save button on top after running the program, what should i do?

  • @diegobuenano5833
    @diegobuenano5833 4 ปีที่แล้ว +1

    Great video 😁
    I have a little question.
    Years ago you made a video to send whatsapp messages from c#, could you update it? Or there is not posible to send messages like that anymore

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว +2

      OK. Let me try to research and update

  • @MusakaGamer
    @MusakaGamer 4 ปีที่แล้ว

    If i copy this program to another computer will i have saved database ?

  • @subhamghosh7033
    @subhamghosh7033 4 ปีที่แล้ว

    I have one question
    I have to create an database application for offline data entry for my client, So can I use this method?
    So do I need to install sql in my cluent pc or just provide him project setup?

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      Yes, you can do the same for sql

  • @challenger7540
    @challenger7540 4 ปีที่แล้ว

    hello thanks for the video. in some vdeos there are both (local database option and service based option) in their visual studio ...but in my visual studio 2013 there is only service based database just like in this video..is there any difference and why i cant see localdb option ?

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว +1

      The same, sql database connect to sql express is local. and attach to sql server, then connect to sql server is sql service. i think so

    • @challenger7540
      @challenger7540 4 ปีที่แล้ว

      @@foxlearn thanks

  • @haydar8545
    @haydar8545 3 ปีที่แล้ว

    Hi fox learn Thanks for all videos, i need help : how to create master details application and insert data into master table and datails table in c#

  • @stanelychiwunga3961
    @stanelychiwunga3961 2 ปีที่แล้ว

    This is fantastic

  • @delta4135
    @delta4135 ปีที่แล้ว +1

    *If someone can't find Data Sources:*
    In my case it was in View > Other windows > Data Sources

  • @foxynight1688
    @foxynight1688 2 ปีที่แล้ว

    thank you for this video !! it easy to understand and make me clearly to do it>>>>

  • @swerytv4342
    @swerytv4342 4 ปีที่แล้ว +4

    Hi fox learn in fact I need a tutorial on how to create a login and authorization system with different selectable roles via Treelist based on my Devexpress ribbon menu. Thank you.

    • @mamadoouboboaissatoudiallo9725
      @mamadoouboboaissatoudiallo9725 4 ปีที่แล้ว

      Well excellente suggestion i need that tutotial toi dear fox Learn

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      OK. Thank you for your suggestion. I'll upload soon !

  • @zamrinjameel3305
    @zamrinjameel3305 4 ปีที่แล้ว +1

    can we prevent data lose on rebuilding the project while using this db method?

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว +1

      Copy your database to another folder, then modify your connection string

  • @chamodkavinda7291
    @chamodkavinda7291 2 ปีที่แล้ว

    Thanks a lot.

  • @kevinfredrick2268
    @kevinfredrick2268 2 ปีที่แล้ว +8

    Thanks but this actually doesn't store the data in the actual database. It only saves the data in the dataset temporarily. So, after closing the application, the data will be deleted and cannot be found in the database. A piece of code is missing in order to physically store the data into the database.

    • @zendpro61
      @zendpro61 2 ปีที่แล้ว +1

      can you learn me how i can store data in database ?

    • @ahmoodk
      @ahmoodk 2 ปีที่แล้ว

      What code do you need for it to permanently save?

    • @tomhrcze
      @tomhrcze 2 ปีที่แล้ว

      @@zendpro61 lkln

    • @zendpro61
      @zendpro61 2 ปีที่แล้ว

      @@tomhrcze you know how ?

    • @osanbrazil999
      @osanbrazil999 ปีที่แล้ว +1

      There's no code missing. Because you are running the program on the original folder, the data in the debug folder is deleted when u run (compile) the app again. Just copy the contents of the debug folder to another folder, e.g. "c:\myapps" and the table data will not be lost after you click on save button. When u run the program again, they'll be there.

  • @davisantos5672
    @davisantos5672 2 ปีที่แล้ว

    Omg! Thanks

  • @dacracking5768
    @dacracking5768 3 ปีที่แล้ว

    OMG. IT WAS THAT EASY!!! FML

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      Thank you !

  • @C0rndawg
    @C0rndawg ปีที่แล้ว

    I'm subcrubesd. Ncie videos.

  • @kaveeshaperera6295
    @kaveeshaperera6295 ปีที่แล้ว

    Thanks a lot

  • @christinemarioneilogon6089
    @christinemarioneilogon6089 ปีที่แล้ว

    do i need internet to access this type of database?

  • @medamine6695
    @medamine6695 3 ปีที่แล้ว +3

    Even after all there years I still can't remember where I heard this ost you are using XD

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว +1

      Thank you !

  • @ikramanjum3722
    @ikramanjum3722 3 ปีที่แล้ว

    excellent

  • @lingeshwarankuppusamy947
    @lingeshwarankuppusamy947 3 ปีที่แล้ว

    Hai please update a video to select multiple database by using combobox method in C# along with with external data base exe setup. I will be very help full for beginners.

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      OK. Thank you for your suggestion. I'll upload soon !

  • @bojidarkamenski3432
    @bojidarkamenski3432 4 ปีที่แล้ว

    Nice video thank you!!!
    Can I ask if someone of you know how to solve this problem I am using ssms 2017 express server on my application it is working properly on my pc but when I am using another pc (aka client machine) it doesn't working - error 26. It is not important I am student who is creating something like school project. I researched in stack or github but no result. Thank you again for this video!

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว +1

      You should install sql express on client machine

    • @bojidarkamenski3432
      @bojidarkamenski3432 4 ปีที่แล้ว

      @@foxlearn ok thank you

  • @rzeezed757
    @rzeezed757 3 ปีที่แล้ว +1

    Is there a way to save the database even when you close the program?

    • @ahmoodk
      @ahmoodk 2 ปีที่แล้ว

      did you find out how to do that

  • @e.h.sojibmia5118
    @e.h.sojibmia5118 3 ปีที่แล้ว

    Nc video
    😍😍😍😍
    🇧🇩🇧🇩🇧🇩🇧🇩

  • @younoushissene9741
    @younoushissene9741 2 ปีที่แล้ว

    This is fri good

  • @andrewdarrensmith1
    @andrewdarrensmith1 2 ปีที่แล้ว

    Nothing displays in the grid view. How can i fix this?

  • @pratibhatechnology7613
    @pratibhatechnology7613 4 ปีที่แล้ว

    according to i create a form and insert value data and show in same form gridview but when i check in folder data not show

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      You should copy data to another folder

  • @deekshasinghchauhan8133
    @deekshasinghchauhan8133 4 ปีที่แล้ว

    Hello, can you tell me How to add reference of microsoft.offic in 2019

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      Right click on your project, then select reference. Next, find the Microsoft.Office..

  • @Guilher.racingdriver
    @Guilher.racingdriver ปีที่แล้ว

    thanks

  • @89Ssik
    @89Ssik ปีที่แล้ว

    When I put FullName, Email, Phone, Gender, Adress for first user it doesn't appear, it starts appearing only from second user, someone know solution? Also Gender in Gridview is just showing check ON/ OFF its not right solution, as you can see in 9:07minutes.

  • @lgoony9909
    @lgoony9909 2 ปีที่แล้ว +1

    Does anyone knows how to change the gender using an edit button?

  • @michelleestrellanes4352
    @michelleestrellanes4352 3 ปีที่แล้ว

    Is this only for one pc? How can it connect to other PC's? Thank you

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว

      Only one pc, if you want to multiple connection you should install sql server, then the clients can connect to sql server

    • @ahmoodk
      @ahmoodk 2 ปีที่แล้ว

      @@foxlearn how do you do that?

  • @georgihristov2553
    @georgihristov2553 2 ปีที่แล้ว

    PLS HELP
    i do everything in this video but now i want to add search button to this code pls help me

  • @selmirmuminovic551
    @selmirmuminovic551 ปีที่แล้ว

    How to add buttons one by one for save, delete, add, and same design like there?

    • @bengali.318
      @bengali.318 11 วันที่ผ่านมา

      hey same problem with me, were you able to find a solution?

  • @bonaoberwinb.9673
    @bonaoberwinb.9673 3 ปีที่แล้ว

    Is the procedure the same in asp net?

  • @myself8709
    @myself8709 ปีที่แล้ว

    Thnku

  • @zulfifarsath
    @zulfifarsath 20 วันที่ผ่านมา

    can you please do money lending project in visual studio C#

  • @shahzaibshahzaib1514
    @shahzaibshahzaib1514 3 ปีที่แล้ว

    is Local DB require Sql Server installation on client machine?
    Thanks:)

    • @foxlearn
      @foxlearn  3 ปีที่แล้ว +1

      Yes, you should install sql express

  • @dedsec96
    @dedsec96 4 ปีที่แล้ว

    how to do auto increment start 1 entity framework? edmx diagram

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      You can set to the table in your database

    • @dedsec96
      @dedsec96 4 ปีที่แล้ว

      @@foxlearn can you send tut?

  • @aldinbeganovic8323
    @aldinbeganovic8323 ปีที่แล้ว

    working bro! Thanks a lot, +sub +like

  • @adeel3797
    @adeel3797 4 ปีที่แล้ว

    Music name?

  • @deiost
    @deiost 4 ปีที่แล้ว

    Very good video, but ModelDataSet contents shown on 3:50 not moving for me so easy with mouse

    • @deiost
      @deiost 4 ปีที่แล้ว +2

      Solved: Had to put VS window back from external monitor on laptop, and everything works perfect

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      Thank you !

  • @Fkn1405
    @Fkn1405 4 ปีที่แล้ว

    Hi there, when i run my project, the local database loses connection which makes impossible to save data from the form to the DB. Do you guys have an idea on how to solve that issue?

    • @dr.kenhurt9832
      @dr.kenhurt9832 4 ปีที่แล้ว +1

      you mean the icon gets a little red cross in its corner? If that it does not mean that the database loses connection. If you look in your project folder there are several databases. The one in the root gets copied to the bin/debug folder everytime you run the project in Visual studio. When you stop running the project that database gets to the state it was before runnig. Try running the exe file in bin/debug filder. It will affect the database in that folder and all the changes must get applied

    • @Fkn1405
      @Fkn1405 4 ปีที่แล้ว

      @@dr.kenhurt9832 ,Thanks!

  • @YAMahaboob
    @YAMahaboob 2 ปีที่แล้ว

    i can't create new table ... why ?

  • @laptrinhwindowsform
    @laptrinhwindowsform 4 ปีที่แล้ว

    Please guide xamarin form c # topic, thanks

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      OK. Thank you for your suggestion !

  • @freezersharp
    @freezersharp ปีที่แล้ว

    The most important part is missing: how can I create that mdf file?

  • @Esp1fs
    @Esp1fs 4 ปีที่แล้ว

    How you publish that app with database?

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว +1

      OK. Thank you for your suggestion. I'll upload soon !

  • @delmarmahamod5990
    @delmarmahamod5990 ปีที่แล้ว

    How to insert photos

  • @MagicGladiatorMandrake
    @MagicGladiatorMandrake 4 ปีที่แล้ว

    This kind of Tutorials began in 2005. it's very old trick. we need the connection code not wizard..

    • @muhammadbilal6865
      @muhammadbilal6865 3 ปีที่แล้ว

      Whats wrong if something can be done in an easy way why you want to hide the things software enginner bro.

  • @whoman0385
    @whoman0385 2 ปีที่แล้ว

    ok. now how do I host the database on a server :gun:

  • @ussr7709
    @ussr7709 3 ปีที่แล้ว +1

    data binding does work WTF

  • @alirezaabedi1885
    @alirezaabedi1885 4 ปีที่แล้ว

    like

    • @foxlearn
      @foxlearn  4 ปีที่แล้ว

      Thank you !

  • @josemarlitoplanteras8829
    @josemarlitoplanteras8829 4 ปีที่แล้ว +1

    cant find my data sources

    • @josemarlitoplanteras8829
      @josemarlitoplanteras8829 4 ปีที่แล้ว

      @@radenazhar3112 nooe but try reinstalling everything

    • @radenazhar3112
      @radenazhar3112 4 ปีที่แล้ว

      @@josemarlitoplanteras8829 does it work bro?

    • @josemarlitoplanteras8829
      @josemarlitoplanteras8829 4 ปีที่แล้ว

      @@radenazhar3112 yee i have freash laptop and I did my installing in there everything work in my laptop but not on oc

  • @melodicmonster
    @melodicmonster 9 หลายเดือนก่อน

    It is good this is not a tutorial on good database or UI design because both are atrocious in the video.

  • @ramzimadene8607
    @ramzimadene8607 3 ปีที่แล้ว

    im a zhee

  • @cyprianskrzypczak1971
    @cyprianskrzypczak1971 3 ปีที่แล้ว +1

    Nowdays gender needs to be stored as a bigint

  • @user-vm3il9vi1q
    @user-vm3il9vi1q 7 หลายเดือนก่อน

    The "gender = bit" is a hot take in today's reality lol

  • @nephytv
    @nephytv 2 ปีที่แล้ว

    wayy to fast lmao

  • @lelouchlamperouge5910
    @lelouchlamperouge5910 2 ปีที่แล้ว

    This don't save any data, useless, a waste of time.

  • @Mibaka
    @Mibaka ปีที่แล้ว

    simple way for connection
    using MySql.Data.MySqlClient;
    using System.Data.SqlClient;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    namespace mudi_13_10_databse_trainings
    {
    public partial class Form1 : Form
    {

    SqlConnection con = new SqlConnection(@"Data Source = LAPTOP-2A5CNVC3\SQLEXPRESS; Initial Catalog = Countries; Integrated Security = True");
    SqlCommand cmd = new SqlCommand();
    public Form1()
    {
    InitializeComponent();
    }
    private void btnClear_Click(object sender, EventArgs e)
    {
    dgvShowData.DataSource = null;
    }
    private void btnExit_Click_1(object sender, EventArgs e)
    {
    Application.Exit();
    }
    private void btnShow_Click_1(object sender, EventArgs e)
    {
    try
    {
    con.Open();
    cmd = new SqlCommand("Select * from Coutnry", con);
    cmd.ExecuteNonQuery();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dtable = new DataTable();
    da.Fill(dtable);
    dgvShowData.DataSource = dtable;
    con.Close();
    }
    catch
    {
    MessageBox.Show("Error 404");
    }
    }
    private void dgvShowData_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
    }
    }
    }