SlashGeek

The online journal of Rebecca Janine Wise

A simple hack to use Visual Studio from Linux

November30

So you want to run Linux on your system and not have to boot into Windows to use Visual Studio? No problem! There’s a catch, of course, as usual: You’ll have to use a Linux Terminal Server Client.

This trick will only work if you are connecting via VPN to your work computer or if you have a Windows development system you can connect to on your home network. Since I have a separate development system running Windows I can just connect to it via RDP (Remote Desktop Protocol) from my laptop which is currently running Ubuntu 5.10. After spending a lot of time trying to get MonoDevelop and Visual Studio to play nice together I think I’ve hit upon the best solution to my needs but your mileage may vary. Over my wireless network RDP performs very well and the Terminal Server Client software is built into the standard Ubuntu install. Good stuff.

Like I said, this is not a perfect solution; it’s just a simple hack that might work for you.


 

Love to code, Hate to release

January5

So everything is ready. I’ve spent days tracking down email addresses for a highly targeted mailing, drafted the email announcement, and prepared the merge. All systems are go.

3…2…1…Mark!

Within a few seconds the emails are winding their way across the Internet, jumping from router to router at near the speed of light. Soon, the web-site that has been the labor of my love for the last six months will be receiving its first few curious visitors and, as we all know, first impressions are all important.

Time to kick back and wait for the kudos to roll in. It’s Miller Time.

Well, not quite. Like all expectant fathers I’m more than a little nervous. I decide that I’ll assuage my fears, however irrational, by logging onto the web-site and verifying that all systems are nominal…

Needless to say, all was not well. The much touted search feature was BROKEN. Not quite dead on arrival, but twitching and ready to be shot in the head. Don’t ask how this managed to slip by the QA department (me) or the programmers (me) but there it was and it was one ugly ass bug.

Anyway, to make a long story short, one caffeine mint and two frenzied hours of coding later the bug was squashed and the patient was in full recovery. I, however, was a nervous wreck.

So what’s the moral of the story? Well, I love to code but hate to release for one. More important, however, is the realization that at some point you have to kick the bird out of the nest to see if it can fly. Be prepared to mend a wing or two when you do though!


 

How to duplicate a SQL database

November3

How to copy a SQL Server database to the same server instance

You would think creating a copy of a database on the same SQL Server server instance would be a point-and-click management task but it isn’t. Here’s a link to the original article. I’ve reposted the code as part of the extended entry in case the original link doesn’t work.

USE master
GO

-- the original database (use 'SET @DB = NULL' to disable backup)
DECLARE @DB varchar(200)
SET @DB = 'PcTopp'

-- the backup filename
DECLARE @BackupFile varchar(2000)
SET @BackupFile = 'c:\pctopp\sqlserver\backup.dat'

-- the new database name
DECLARE @TestDB varchar(200)
SET @TestDB = 'TestDB'

-- the new database files without .mdf/.ldf
DECLARE @RestoreFile varchar(2000)
SET @RestoreFile = 'c:\pctopp\sqlserver\backup'

-- ****************************************************************
-- no change below this line
-- ****************************************************************

DECLARE @query varchar(2000)

DECLARE @DataFile varchar(2000)
SET @DataFile = @RestoreFile + '.mdf'

DECLARE @LogFile varchar(2000)
SET @LogFile = @RestoreFile + '.ldf'

IF @DB IS NOT NULL
BEGIN

SET @query = 'BACKUP DATABASE ' + @DB + ' TO DISK = ' + QUOTENAME(@BackupFile, '''')
EXEC (@query)

END

-- RESTORE FILELISTONLY FROM DISK = 'C:\temp\backup.dat'
-- RESTORE HEADERONLY FROM DISK = 'C:\temp\backup.dat'
-- RESTORE LABELONLY FROM DISK = 'C:\temp\backup.dat'
-- RESTORE VERIFYONLY FROM DISK = 'C:\temp\backup.dat'

IF EXISTS(SELECT * FROM sysdatabases WHERE name = @TestDB)
BEGIN

SET @query = 'DROP DATABASE ' + @TestDB
EXEC (@query)

END

RESTORE HEADERONLY FROM DISK = @BackupFile
DECLARE @File int
SET @File = @@ROWCOUNT

DECLARE @Data varchar(500)
DECLARE @Log varchar(500)

SET @query = 'RESTORE FILELISTONLY FROM DISK = ' + QUOTENAME(@BackupFile , '''')

CREATE TABLE #restoretemp
(
LogicalName varchar(500),
PhysicalName varchar(500),
type varchar(10),
FilegroupName varchar(200),
size int,
maxsize bigint
)

INSERT #restoretemp EXEC (@query)
SELECT @Data = LogicalName FROM #restoretemp WHERE type = 'D'
SELECT @Log = LogicalName FROM #restoretemp WHERE type = 'L'

PRINT @Data
PRINT @Log

TRUNCATE TABLE #restoretemp
DROP TABLE #restoretemp

IF @File > 0
BEGIN
SET @query = 'RESTORE DATABASE ' + @TestDB + ' FROM DISK = ' + QUOTENAME(@BackupFile, '''') +
' WITH MOVE ' + QUOTENAME(@Data, '''') + ' TO ' + QUOTENAME(@DataFile, '''') + ', MOVE ' +
QUOTENAME(@Log, '''') + ' TO ' + QUOTENAME(@LogFile, '''') + ', FILE = ' + CONVERT(varchar, @File)

EXEC (@query)

END

GO


 
« Older Entries