|
i call this method by button and this exception appeare
exception "Backup failed for Server"
public void BackupDatabase(String databaseName, String destinationPath)
{
Backup sqlBackup = new Backup();
sqlBackup.Action = BackupActionType.Database;
sqlBackup.BackupSetDescription = "FollowUPBackUP:" + DateTime.Now.ToShortDateString();
sqlBackup.BackupSetName = "FollowUP";
sqlBackup.Database = databaseName;
BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
string instantname = @".\sqlexpress";
ServerConnection connection = new ServerConnection(instantname);
Server sqlServer = new Server(connection);
Database db = sqlServer.Databases[databaseName];
sqlBackup.Initialize = true;
sqlBackup.Checksum = true;
sqlBackup.ContinueAfterError = true;
sqlBackup.Devices.Add(deviceItem);
sqlBackup.Incremental = false;
sqlBackup.ExpirationDate = DateTime.Now.AddDays(10);
sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;
sqlBackup.FormatMedia = false;
sqlBackup.SqlBackup(sqlServer);
}
modified on Wednesday, December 1, 2010 1:17 AM
|
|
|
|
|
I'm pretty sure that the error message was longer than just "Backup failed for Server". If it was then it might help people, to help you, if you edited your question to include the full message.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Why would you want to do this?
|
|
|
|
|
Hi Pete,
Are you able to help?
I'm having a problem with remote desktop logging off the local machine when the remote session is ended. Even if this is only a temporary work around until I figure out why this is happening with vista and not xp, I would like to implement it immediately.
|
|
|
|
|
I've used a version of this code in the past, and it works fine. What problem are you having with it?
|
|
|
|
|
It won't compile and there are duplicate code entries as well as some other things I had to do to get it to compile.
I have something that compiled and did work as far as stopping me from logging off when I'm in front of the machine, but it still doesn't seem to block the machine from logging off when the remote desktop session is disconnected.
|
|
|
|
|
I'm not aware of anything that will prevent this happening when the remote desktop session disconnected.
|
|
|
|
|
Somehow it isn't an issue when I take an XP machine and remote desktop into a Vista machine. The session is saved when the XP machine is disconnected, etc.
When it is vista to vista, the problems start occurring. There has to be a way to emulate what is happening with XP.
|
|
|
|
|
I'm sorry that I can't help you. I'll be watching this with a lot of interest. I hope you get it resolved soon.
|
|
|
|
|
Thanks!
This worked last night, I'll continue to test it throughout the week. I wrapped it in a c# application that blocks logging off without verification first. The same can be done for XP, but the first command is a bit different, it is " tscon 0 /dest:console " instead.
I through the wait commands in, because a few times that I was testing it would release the session before the lock command could run and then it would not lock the machine, so an unlocked desktop was left sitting at the office, not something I wanted to happen. Thanks for the help and encouragement Pete.
tscon.exe RDP-Tcp#0 /dest:console
wait 1
rundll32.exe user32.dll, LockWorkStation
wait 1
exit
|
|
|
|
|
|
How could one reboot a local computer to safe mode using C#?
I have used google to search for this and not finding much. I did find a question posted for the exact same thing here on codeproject from '06 but the reply the guy got was this was not possible.
I see this for shutting down or rebooting:
http://pinvoke.net/default.aspx/wtsapi32/WTSShutdownSystem.html[^]
Before you say this cannot be done, I currently use a Windows application that can reboot a computer to safe mode. Not sure how they do it, but they are somehow.
|
|
|
|
|
I have never tried this but your question intrigued me so I did a little googling.
If the OS on the computer is XP or before how about temporarily editing Boot.ini to add a /SAFEBOOT switch (source[^]), with a runonce registry entry to reset afterwards.
I'm not sure how Vista and Weven work but a similar technique might be possible.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Well you came up with more than I did. I was hoping to get around manually editing the boot ini file with my code. Even if I did that would it go off once it booted into safe mode or will it continue to boot into safe mode every time it reboots?
Note:
I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?
|
|
|
|
|
Jacob D Dixon wrote: Note:
I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?
Probably not, if you use the code directly. Although if it's not obfuscated there is no harm in just having a look, to satisfy your curiosity.
I used to do a similar thing back in the DOS days with the Autoexec.bat and Config.sys for some programs (Games mostly) that required non standard settings.
In your situation, make a copy of Boot.ini, rename it Boot.ini.safe (safe mode), or similar. Make another copy and rename it Boot.ini.std (standard mode). Modify the .safe file to include the /SAFEBOOT stuff.
BTW: Try the next bit out manually first, to make sure that it works.
I used to do the next bit using batch files, you could do the same, or write a small app to do it.
1. Delete Boot.ini
2. Depending on whether you're going from standard to safe, or the other way, copy the Boot.ini.safe/Boot.ini.std file as Boot.ini.
4. When going to Safe mode add the entry to Runonce in the registry to run the app/batch that prepares for standard boot on next restart.
3. Restart.
[Edit]
Just discovered that step 4, above won't work See Notes section in this[^].
Hmmm and it seemed like such a good idea.
[/Edit]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
LOL.
Let me give some things a try. Your suggestions got me further than I was. There are some things that I want to know how this application does stuff. It also provides like a VNC redirecting type function where the control center application is on your computer, then you have the server, then you have agents (which could be on a different network behind a different firewall). So the agent started the VNC with the server, then somehow the server redirects all that traffic to the control center.
It is all a learning curb for me. So my way of learning is trying to duplicate the server / client application they made (slimmed down version of course).
Let me try some things and also snoop around in their code and I'll let you know what info I come up with. thanks for the information you already provided!
|
|
|
|
|
thanks to both of you.. now I know how to do routine at least it works.. I usually restart to Safe/DOS mode to remove manually the Autorun.inf of any USB Drive suspected with virus. this at least I can prevent it from transferring to my hard drive. I just copy only the Docs and Xls files.
|
|
|
|
|
I am trying to change the "onload" event of the Body in a frame. My problem is when I using the GetAttribute method on the Body it returns "System._ComObject" as a string rather than the attributes value. Please note it is not returning an object of System._ComObject, just the string.
I tried just doing the change via Body.OuterHtml but that throws an expception of NotSupportedException. Which is odd seeing as it is a property that says it allows "get and set" operations.
WebBrowser.Document.Window.Frames[i].Document.Body.GetAttribute("onload") = "System.__ComObject"
Any ideas on how to get this to behave as it should would be greatly appreciated. Even just a point in maybe the right direction. Also I did try this using "mshtml" objects and all it got me was the actual System._ComObject. However, I had no idea how to covert that to the string it was supposed to actually represent.
|
|
|
|
|
From a (very) quick google it seems that that is the expected behaviour.
Some of the hits I got suggest using
WebBrowser.Document.Window.Frames[i].Document.Body.GetAttribute("onload").Name
WebBrowser.Document.Window.Frames[i].Document.Body.GetAttribute("onload").GetInterfaces()
Although it seems that does not always work.
In case you want to dig deeper I used c# system.__comobject as my search term. Nearly all the first page were about people having similar problems as yourself.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks when I googled I must have been using the wrong search terms. I found a work around I just regexed the onload out of the body tag, then set the onload attribute the way I wanted it. Not the solution I wanted, but hey it works for what I needed.
But doing it the right way will be more important when I start doing form fills on that page. I just wanted to keep this stupid popup alert that is in the body's onload event from activating.
|
|
|
|
|
Hello,
When I'm running in debug in a window console application (C#) I've noticed that I can't use thing like "windows key + E" to open the explorer windows and so on.
If for example I'm pressing twice on WIN+E - nothing happen.
Now - I can use the F10 key to continue the debug and stuff but only after I'm pressing the STOP icon and the debug is stopped. only then All the other key press are jumping in
Any body know this issue?
Thanks.
|
|
|
|
|
Maybe Visual Studio is swallowing your special key combinations?
You could try to disable the "Visual Studio hosting process" (see project properties, debug).
|
|
|
|
|
Luc, Can I marry you?
Thanks, Looks like it worked.
|
|
|
|
|
I am logging data from a USB device (pooling the device) using a timer component with C#.
Every 250ms (timer tick) I read the data from the device and save it to a CSV (coma separated value) file.
I just thought I should ask if there is anyway to improve on the saving of the file. I am new to C#/.net so would really like a review of the idea.
1. Every timer tick I read two values from an object (the USB device interface).
2. Open the file by creating a Steame writer object;
StreamWrite out = new StreamWriter(filename, true).
3.Write the values to the file
out.Writeline("{0},{1}",value1,value2);
4.Close the file.
out.close();
The main question is should I keep opening and closing the file every tick or should I open it when the logging starts and close it when the user stops the logging of the data? The reason I close the file is so if the application fails I do not lose any data.( the file is being used only by this application).
Any comments to improve the code will be useful.
Thanks cages
|
|
|
|