Backing Up Your SQL Server Database To SQL Files With Management Studio Express
A common need in the ASP.NET world is how to back up a remote SQL Server database, usually provided by someone else. Sometimes, you want to occasionally run a backup as an extra layer of redundancy; other times, you are changing hosts or want to be ready to do so.
How you back up a remote SQL Server database depends largely, if not entirely, on the tools your Web host is willing to give you.
Most Web service providers will give you some implementation of a BACKUP Transact-SQL query; the resulting .bak file is then either put into a directory on your Web server, or you’re given a download link. And generally speaking, that .bak file is enough to create a fresh version of your database, either at the same host or someplace else.
But not always. You generally can’t be sure of the integrity of a .bak file run by a Web service provider; you also may find that, due to the way that WSP’s servers are configured, the backup file it creates won’t work elsewhere, or are problematic to use. I’ve had bad luck using .bak files to replicate databases between Web service providers.
Another option is to simply download the remote database’s MDF file. I like this approach best because as a rule, if you have the relevant MDF file and the same version of SQL Server, you can simply attach the MDF file to a new SQL Server instance, and it’s like the database was there all along.
There are two more options available — again, depending on how your Web service provider allows you to connect to the remote database — and I’ll blog on both.
Today, I’ll discuss using SQL Server Management Studio Express, and its built-in scripting tools, to dump your remote database to SQL command files. Next time, I’ll write an ASP.NET script that will back up our database to SQL files.
Continue reading: Backing Up Your SQL Server Database To SQL Files With Management Studio Express »
Killing Tynt’s “Read More” Clipboard Copy Hijacker With The Adblock Plus Plug-In For Firefox
I love Firefox. It’s pretty much the only Web browser I use.
I hate Tynt. If you’ve ever copied text from a Web page, then pasted it, only to find a mysterious “Read More:” link inserted at the end of the text you copied, you just ran headfirst into Tynt.
Each time a user pastes content from your website into an email, blog or website, we automatically add a URL link back to your site’s original content. When someone clicks that URL, they are directed back to your site and see the original content. This drives incremental traffic to your site when your content is shared without your knowledge while maintaining a consistent user experience.
It may well be a “consistent user experience” for me to have to hit the backspace key to delete the “Read more” link Tynt adds every time I copy a small block of text, but it’s a consistently annoying experience.
I appreciate the importance of reciprocal links. I understand the challenge to content publishers of having content lifted from their Web sites without attribution.
So before I get into details about this fix, let me be clear: If you copy Web content, attribute it. It’s the right thing to do.
That said, there’s a wrong way of getting people to do the right thing, and Tynt is definitely the wrong way.
I find having my simple act of extracting a quote from a Web page turned into a link-spamming takeover of my local machine to be far more disturbing than a tracking cookie or layer ad.
Don’t be messing with my clipboard. It’s mine, not yours. I will put into it what I want there, not what you want.
Fortunately, I was able to put an immediate end to Tynt’s “Read More” clipboard copy highjacking in Firefox with Adblock Plus, a highly popular add-in that does what its name suggests: Blocks advertisements, and other content, from displaying on a page.
How To (Not) Add Numbers In JavaScript, And How To Troll
And now, for some levity, courtesy of Andrew Clover at doxdesk.com: An obvious trolling of Stack Overflow (and one which they have removed), but a funny one, nonetheless.
(Click for full-size pic)
So full of win, from start to finish. Even the “Related” links are hilarious. FYI, bobince — the straight man in this joke — is Clover.
All links in this post: http://delicious.com/dougvdotcom/how-to-not-add-numbers-in-javascript-and-how-to-troll
Good Coding Practices Should Replace Comments In Code
I recently came across a post on elegantcode.com that really struck a nerve. The premise: If you write good code, comments should not only be unnecessary, they could actually be counterproductive. Says author John Sonmez:
“As my experience has increased, I have realized more and more that comments are actually bad. They indicate a failure.”
I know that this runs contrary to what most professors, instructors and textbooks say. They offer what seems a reasonable rule: Comment your code so that the next person who reads it doesn’t need to try to figure out what you’re doing.
And it’s also contrary to most of the code I put out on this Web site. I would certainly agree that I over-comment my code, but that’s a conscious decision, based in large part because I want my readers, who tend to be newer programmers, to completely understand what my code is doing at each step.
But as Sonmez notes, comments aren’t the best way to achieve that goal, especially in object-oriented code.
For example, if you change code, its related comment doesn’t change. Use proper constants — e.g., DEFAULT_LOOP_ITERATIONS — instead of a variable declarations. Name your methods, properties and function so they are self-documenting (do you really need to comment a method named OpenXMLFile?) and write more code so that self-documenting names can replace more abstract procedural code calls.
It’s this third suggestion that interests me. I’ve said, many times, that less code is better. I maintain that view. But I’m inclined to agree more with Sonmez that, if it takes a few extra lines and a couple more dependencies to create self-documenting code, that complexity is probably the right trade-off, versus adding novella-sized comment blocks.
I’m almost certainly going to continue over-commenting code here, especially because I am trying to serve the needs of novice programmers.
But Sonmez’s brilliant post really hits hard, and reminds me that if I am trying to write simple code that’s easy to understand, I should rely more on best programming practices than double-slashes. Expect to see more of that in the future. And please do take the time to read his post in full.
All links in this post on delicious: http://delicious.com/dougvdotcom/good-coding-practices-should-replace-comments-in-code
MSDN Northeast Roadshow: Sept. 24 in Augusta, ME
The MSDN Roadshow returns to Augusta, ME and the Central Maine Commerce Center’s Florian Auditorium on Sept. 24, from 1 p.m. – 6 p.m. (That’s a later start than recent roadshows, because directly before it, there’s a TechNet event about Windows 7 and Remote Desktop.)
MSDN Roadshows are a chance for Microsoft evangelists — namely, Chris Bowen and Jim O’Neil — to describe new technologies, demonstrate how to program in Microsoft languages and platforms, and generally share the word about what’s new and on Microsoft’s mind at the moment.
Among the issues to be discussed at this roadshow is Windows 7. Without question, Chris and Jim know their stuff, and you’ll definitely walk away from this event with a better knowledge of Microsoft technologies — if not some of the loot they give out at every event (fully-functional copies of Windows Vista, Visual Developer 2008 Professional, Microsoft Press books and peripherals having been offered in the past as door prizes).
Florian Auditorium and the Central Maine Commerce Center are in the former SCI Systems / Digital Equipment plant off Civic Center Drive. I have a public Google Map of the location.
If Augusta or the date are not convenient for you, Chris and Jim are doing the same agenda in Manchester, NH; Rochester, NY; Troy, NY; Waltham, MA and Farmington, MA. Chris Bowen details it all on his blog.



