C# Tutorial - Backup Database SQL Server | FoxLearn

Sdílet
Vložit
  • čas přidán 10. 12. 2016
  • C# Database Programming: Backup Database SQL Server in C#. The C# Basics beginner course is a free C# Tutorial Series that helps beginning programmers learn the basics of the C# Programming Language. This is the best way to Learn C# for beginners
    Backup & Restore Sql Server database in C#
    SQL Server Database Backup and Restore using C#
    Take BackUp of SQL server Database using C#
    .net - How to backup Sql Database Programmatically in C#
    SQL Server Database Backup and Restore in C# - CodeProject
    Backing up an SQL Database in C# - CodeProject
    Creating SQL Server Backup File With C#

Komentáře • 115

  • @alm0nd.359
    @alm0nd.359 Před 3 lety

    Thanks Foxlearn, you helped me a lot of :°)

  • @ymn76ymn
    @ymn76ymn Před 6 lety

    There was error for me, because I have VS 2013 , I replaced with string.Format("{0}%",e.Percent) as you said , but nothing happened . please help..

  • @estebangiraldo9792
    @estebangiraldo9792 Před rokem

    to compress the backup which property should i use

  • @ahmedsalah6061
    @ahmedsalah6061 Před 5 lety

    thank you very much for this helpful video

    • @foxlearn
      @foxlearn  Před 5 lety +1

      You're welcome. Thank you !

  • @MrValen1984
    @MrValen1984 Před rokem

    I'm getting empty columns when restoring my backup...am I doing something wrong?...on the other hand the progress bar for my restore does not work...Thank you.

  • @samuelsenauluquipa445
    @samuelsenauluquipa445 Před 3 lety

    my problem is that the DbBackup_PercentComplete method never gets executed. thanks

  • @programador101
    @programador101 Před 3 lety +1

    I can not find the libraries in vs 2017 also I have installed sql server 2017 :(

  • @estebanyanson
    @estebanyanson Před 2 lety +1

    How can I get backup file from remote sql server ?
    Thanks

  • @dansad9475
    @dansad9475 Před 7 lety

    why i code as above but don't backup ? Please help me

  • @alqbati2023
    @alqbati2023 Před 4 lety

    Thank you very much

  • @rjevangelista9769
    @rjevangelista9769 Před 5 lety

    Thanks! But how can I achieve to exclude specific table on backup?

    • @foxlearn
      @foxlearn  Před 5 lety

      You should generate a script, then you can run the script for the specified table. Thank you !

  • @bishoynabil5303
    @bishoynabil5303 Před 4 lety

    thank you

  • @pulasthibasnayake403
    @pulasthibasnayake403 Před 6 lety

    Backup failed for Server .why is that??

  • @josemenendez6219
    @josemenendez6219 Před rokem

    Great Video but Will be cool if we were able to save it in the local computer using the application. For Example, I have a VPS and I like to Do backups without entering the VPS. So Doing the backup from my local computer and getting that file in my local computer without entering my vps will be awesome.

  • @sygex5266
    @sygex5266 Před 4 lety

    Hello there, Backup failed for Server . on Visual studio 13?!

    • @foxlearn
      @foxlearn  Před 4 lety

      Please check your code again. I think you miss something.

  • @victorjoaquin4
    @victorjoaquin4 Před 2 lety

    Donde lo descargo ese ejemplo

  • @ahsanali3857
    @ahsanali3857 Před 7 lety

    how to store this backup to UBS or Dropbox using c#

    • @foxlearn
      @foxlearn  Před 7 lety +1

      Ok. Thank you for your suggestion

  • @adeelsiddiq186
    @adeelsiddiq186 Před 3 lety

    No Library/extension/Reference found to add in my C# project that you added in your video for taking backup of SQL server I am using visual studio 2013 please help me out if there's any change now
    thanks in advance

    • @foxlearn
      @foxlearn  Před 3 lety

      You should install sql management studio, then you can get the library

    • @adeelsiddiq186
      @adeelsiddiq186 Před 3 lety

      @@foxlearn sql management studio is installed and project is working properly in sql and wi dows forms as well 😥

  • @eamchet2680
    @eamchet2680 Před 3 lety

    Hi Fox Learn
    I have use Oracle 12c can you help me create app backup?
    Thanks

    • @foxlearn
      @foxlearn  Před 3 lety

      sorry man. i don't use oracle

  • @CarlosGarcia-ct2mv
    @CarlosGarcia-ct2mv Před 7 lety

    I have a problem with progressbar , not update .
    thank you so much :D

    • @foxlearn
      @foxlearn  Před 7 lety +1

      Hi, You need to set value to your progress bar in backup event. Please try again. Thank you

  • @myvominh6667
    @myvominh6667 Před 7 lety

    Can u tell me where you take this voice for all video of your channel. Sound like voice of some OS.... Thanks

    • @foxlearn
      @foxlearn  Před 7 lety +1

      Natural text to speech. Thanks

  • @maherbabar3315
    @maherbabar3315 Před 6 lety

    How can i use this code on windows authentication
    I did not create Sql Sever Authentication Help me plz

  • @gustavolopes4066
    @gustavolopes4066 Před 3 lety

    Alguém poderia me ajudar ? no Visual Studio 2019 não estou conseguindo adicionar a dependência que foi utilizado no vídeo

  • @muhammadziadibrahim8078

    The code works fine. Thanks.
    But does it work on big databases too?

  • @challenger7540
    @challenger7540 Před 4 lety

    there are no those 4 libraries in vis.st.2013 how will we add ?

  • @yourspdahal5606
    @yourspdahal5606 Před 4 lety

    how to closed my form when await task finished. l have a large database back time out problem . i hope this process solve but not closed my form when task completed. please help me .

    • @yourspdahal5606
      @yourspdahal5606 Před 4 lety

      no reply

    • @foxlearn
      @foxlearn  Před 4 lety

      this.Close()

    • @yourspdahal5606
      @yourspdahal5606 Před 4 lety

      @@foxlearn System.InvalidOperationException was unhandled by user code
      HResult=-2146233079
      Message=Cross-thread operation not valid: Control 'BackupsFiles' accessed from a thread other than the thread it was created on.
      Source=System.Windows.Forms
      StackTrace:
      at System.Windows.Forms.Control.get_Handle()
      at System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, Int32 lparam)
      at System.Windows.Forms.Form.Close()
      at CoopSoft.BackupsFiles.pricesscompletedall() in d:\NASABACKUP\CoopSoft\CoopSoft\BackupsFiles.cs:line 184
      at CoopSoft.BackupsFiles.dbbackup_PercentComplete(Object sender, PercentCompleteEventArgs e) in d:\NASABACKUP\CoopSoft\CoopSoft\BackupsFiles.cs:line 114
      at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.OnInfoMessage(Object sender, ServerMessageEventArgs e)
      at Microsoft.SqlServer.Management.Common.ServerMessageEventHandler.Invoke(Object sender, ServerMessageEventArgs e)
      at Microsoft.SqlServer.Management.Common.ConnectionManager.SerializeInfoMessage(Object sender, SqlInfoMessageEventArgs e)
      at System.Data.SqlClient.SqlConnection.OnInfoMessage(SqlInfoMessageEventArgs imevent, Boolean& notified)
      InnerException:

  • @challenger7540
    @challenger7540 Před 4 lety

    say we have a program with database..How can we back up database while it s working ?(local db)

    • @foxlearn
      @foxlearn  Před 4 lety +1

      You should set your database is single user, then backup. Next, back on multiple user

    • @challenger7540
      @challenger7540 Před 4 lety

      @@foxlearn this time it says "User does not have permission to alter database 'mydb', the database does not exist, or the database is not in a state that allows access checks."

  • @mohamednaser2128
    @mohamednaser2128 Před 5 lety

    Error 7 The type 'Microsoft.SqlServer.Management.Sdk.Sfc.IAlienObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'. C:\Users\Mohamed\Desktop\Ray_Connect\Ray_Connect\Ray_Connect\Form_backup.cs 55 17 Ray_Connect
    hi the error fix Please

    • @foxlearn
      @foxlearn  Před 5 lety +1

      You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc

    • @mohamednaser2128
      @mohamednaser2128 Před 5 lety

      @@foxlearn Thank you for your response, but can you explain more

    • @pritiwagh6164
      @pritiwagh6164 Před rokem

      @@foxlearn how to add refrences

  • @chuckt5930
    @chuckt5930 Před 7 lety

    these characters $ and % are giving an error how did you do it foxlearn

    • @chacataplan
      @chacataplan Před 7 lety

      $"{e.Percent}%"; pls error

    • @foxlearn
      @foxlearn  Před 7 lety +1

      Hi, It using in C# 6.0, you can replace string.Format("{0}%",e.Percent). thanks

    • @ymn76ymn
      @ymn76ymn Před 6 lety

      If you have no VS 2015 you can't using the $ " " , but there is another way .. string.Format("{0}%",e.Perecent)

  • @fadisayy392
    @fadisayy392 Před rokem

    how to download this libraries?

  • @wordpresswithdhaval4161

    it is posible to backup the data from local database

    • @foxlearn
      @foxlearn  Před 7 lety +1

      Yes, You can backup data from local database

    • @wordpresswithdhaval4161
      @wordpresswithdhaval4161 Před 7 lety

      how can give me code
      on this Id gevariyadhaval@gmail.com

    • @wordpresswithdhaval4161
      @wordpresswithdhaval4161 Před 7 lety

      otherwise can you give me some idea how to backup data in local database with .net c#

    • @foxlearn
      @foxlearn  Před 7 lety

      Similar code, only need to change your connection string

    • @challenger7540
      @challenger7540 Před 4 lety

      @@foxlearn say we have a program with database..How can we back up db while it s working ?

  • @TuanHoang-fy2ws
    @TuanHoang-fy2ws Před 4 lety

    Chào ad, mình đã làm giống hệt bạn mà lúc backup không được, cũng không báo lỗi gì . Bạn hướng dẫn mình với

    • @foxlearn
      @foxlearn  Před 4 lety +1

      What error are you getting? thank you !

    • @TuanHoang-fy2ws
      @TuanHoang-fy2ws Před 4 lety

      @@foxlearn cảm ơn ad. Mình tìm ra lỗi rồi. Các bài viết của bạn rất có ích

    •  Před 3 lety

      @@TuanHoang-fy2ws bạn fix ntn vậy? mình bấm vào cũng không có báo lỗi gì hết nhưng nó không chạy

  • @anshuvishwakarma6020
    @anshuvishwakarma6020 Před 4 lety

    How to create autobackup.

    • @foxlearn
      @foxlearn  Před 4 lety

      You can create a schedule in your sql server

  • @flutterify
    @flutterify Před 5 lety

    i didn't find the libraries in vs2013

    • @foxlearn
      @foxlearn  Před 5 lety +1

      You should install sql server, then you can find the library

    • @flutterify
      @flutterify Před 5 lety

      @@foxlearn i am working with local database how do i backup local database

  • @Ahmad_Hamdy_Hamdeen
    @Ahmad_Hamdy_Hamdeen Před 2 lety

    sql query:
    Backup DATABASE [DatabaseName] TO DISK = N'D:Back.back'
    😍😍

  • @Noss454
    @Noss454 Před 5 lety

    Access Denied :( And I can not solve with code.

    • @foxlearn
      @foxlearn  Před 5 lety

      I think you should set permission allows you to access the backup file

    • @Noss454
      @Noss454 Před 5 lety

      I know, but i can't do this manually. Set permission via script ^^

  • @victorjoaquin4
    @victorjoaquin4 Před 2 lety

    Fuentes

  • @Ahmad_Hamdy_Hamdeen
    @Ahmad_Hamdy_Hamdeen Před 2 lety

    using (var context = new ApplicationDbContext())
    {
    string currentDatetime = DateTime.Now.ToString("yyyy-MM-dd 'at' HH.mm");
    string backupPath =
    $@"Backup DATABASE [DatabaseName] TO DISK = N'{Environment.CurrentDirectory}\Backups\{currentDatetime} Backup'";
    context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, backupPath);
    }