473,769 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create SQL Backup with SQLDMO.dll

Hi all,

I want to create a backup of a database using SQLDMO in C#. But I keep
on getting a exception. If anyone can help me by providing code for
this, it would be appreciated. Thanks in advance...

Code:
+++++++++
try
{
this.Cursor = Cursors.WaitCur sor;
SQLDMO._SQLServ er srv = new SQLDMO.SQLServe rClass();
srv.Connect("se rver","username ","password ");

SQLDMO.Backup bak = new SQLDMO.BackupCl ass();
bak.Devices = bak.Files;
string path = txtPath.Text; //Path where the backup should be
created.
path = "[" + path + "]";
bak.Files = path;
bak.Database = "DatabaseNa me";
bak.SQLBackup(s rv);

MessageBox.Show ("Database backed up successfully.", "Backup
Successfull");
this.Cursor = Cursors.Default ;
}
catch(Exception err)
{
this.Cursor = Cursors.Default ;
MessageBox.Show (err.Message,"E rror");
}

Exception
++++++++++

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open backup
device 'C:\test\Backup Name.BAK'. Device error or device off-line. See
SQL Server error log for more details.
[Microsoft][ODBC SQL Server Driver][SQL Server]BACKUP DATABASE is
terminating abnormally.
Paul

Dec 8 '05 #1
1 5767
Sorry, no need to reply on this post, it was my own stupidity that
caused that exception. The code works perfectly...

Paul

Dec 8 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4455
by: acko bogicevic | last post by:
Hi everyone I have the folowing situations with my backups. With Database Maintenance Plan is created backup strategy. Full Backup is performing every day at 1.00 am. And Romove files older than: is checked on 2 days, and it's working fine. I am interested how can i perform this action with tsql, without using DMPlan. I tryed this: BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2
2
2132
by: Alberto | last post by:
I need a tool that creates a script to recreate a db, including tables' data. Does it exists freeware ? thanks!
1
2013
by: john_20_28_2000 | last post by:
Will osql product an SQL backup? By this I mean a text file with the transact-sql in it so I can use it to recreate the database elsewhere? Thank you.
0
1495
by: Chandra | last post by:
Hi, I tried the following: >>> from win32com.client import DispatchWithEvents >>> class BackupEvent: .... def OnPercentComplete(self, sMessage, nPercent): .... print sMessage, nPercent
2
812
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I`m using MS-SQL server to make my database\and connect to it using C# is there any way that I can make a backup to my database using C# thanks Mohammed
3
5312
by: T. | last post by:
I dumped VB and adopted C# for this version of Visual Studio. My problem! I am trying to reference an SQLDMO.Database object in C# like so: private SQLDMO.Database dbcurrent; private string dbname; dbname = "Northwind"; dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname); But I get this error : No overload for method 'Item' takes '1' arguments.
1
7563
by: | last post by:
Hi all My requirement is to "on button_click, backup a SQL database using SQLDMO.Backup object and update the progress in a ProgressBar. The problem is the progress bar does not update at all until the very end of the backup process, when the backup is almost going to be over, the progress bar updates itself once on a stretch, which is no use,it is not showing any progress. SQLDMO documentation says, the SQLDMO.Backup object fires
1
2558
by: | last post by:
Hi all I am posting this to check if anyone could help me. The problem still persists. I am beginner in C#. Thanks. Subject: SQLDMO.Backup and ProgressBar - help please From: "anonymous@discussions.microsoft.com" <anonymous@discussions.microsoft.com> Sent: 11/11/2004 5:52:10 AM
0
3881
by: MikeB | last post by:
Problem : I am maintaining a legacy application which is distributed with a default database, loaded from a file called Master.dat. I wish to update the values of 10 fields in 1 table. I can restore a database from Master.dat within the (C++ and SQLDMO) app. If I try to restore from command line osql, the restore fails :
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.