Most of us use Ctrl + F or Ctrl + Shift + F to find code. However you can also use a Ctrl + I which is the Incremental Search. The nice thing about this is you don’t have to wait for the dialog. Just hit Ctrl + i , and as you type it will match the string being typed.
A straight to the point and sometimes comical site that aggregates technology information and attempts to apply it towards stuff.
Thursday, June 9, 2011
Visual Studio Break When Exception Thrown
Maybe some of you know this, maybe some of you don’t. But I just learned about it. Apparently I’m a old man programmer because I normally just look at the code and try to solve it without debugging the application, or I write it out somewhere.
I’ve been trying to track down this wiggly bug in my factory pattern code, but it was a slippery bugger. I finally asked somebody for some help and they suggested that instead of all my try/catch’s I use the Break when Exception is thrown. By default Visual Studio only breaks when the exception is unhandled in the user code. For me this was some distance from where the exception was thrown.
So if you want to throw the error in the code where the error occurs and not wait for it to catch. You can select the Debug menu, then Exceptions (or use Ctrl-Alt-E) which will bring up this dialog box:
Check the box under Thrown for the “Common Language Runtime Exceptions and viola. You are set.
Monday, August 9, 2010
Using MKLINK to create a Symbolic Link
With 64 bit systems you might be writing a bat file and you might want to generate your folder in the Program Files (x86). However to help make life easier for your user you could also create a symbolic link to the Program Files as well which is more or less a shortcut to your folder.
In my company we use Marimba to deploy to our shop servers. As stated above I wanted to create a symbolic link to my Program Files. Below is how I did it.
- Open Command Prompt (Admin). Start –> type “cmd” in search and hit Ctrl + Shift + Enter and it will open in Administrator mode, or hit Windows + R and type in “Cmd” either way works.
- Just to get a quick look at what MKLink. Type “mklink /?” to look at the help info.
- My command line looked like this: mklink /D “C:\Program Files\marimba” “C:\Program Files (x86)\marimba”
- The command line response was: “symbolic link created for C:\Program Files\marimba <<==>> c:\Program Files (x86)\marimba.”
- Browse to my C:\Program Files, and now I see a marimba folder that when I click it, takes me to my real URI location.
Wednesday, June 9, 2010
Using SQLCMD to execute multiple SQL Scripts in folder
My company utilizes a midnight installer process that rebuilds a database every night for a {QA, Prod} environment. But sometimes we the developers need to rebuild our databases from these scripts. Previously I would open up the query window. Assemble all the scripts from each file into one file. Copy and paste all the sql scripts details into the query window and execute. Bleh, slow and I hated it. But now if I need to execute a bunch of sql scripts I can do so in a batch file.
- First I want to open up a “run as” admin command prompt.
- Start –> “Search Program and Files”, type in “cmd” this should auto focus on cmd.exe found.
- Then hit “ctrl” + “shift” + “enter” and it will open up a command prompt in administration mode. You can tell because the command prompt will say “Administrator.”
- Normally I just opened up sql query and copy and pasted the single scripts that run the create database and constraints/foreign key scripts. But now I need to add all the stored procedures. In our company we keep a static database of that product with all of our stored procedures to keep them all in once location. With one table “About” for versioning the set of stored procedures/functions etc. So I will browse to my current TFS workspace location. In my case: “cd C:\srs_source\Team\Product\Main\Databases\ProductCode\Database\Programmability\Stored Procedures”.
- Now I use the command line “dir /b > myFile.cmd” (dir /b list directory with the format I want) and the greater than sign “>” (writes the command output to a file, instead of the command prompt window).http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
- Open up “myFile.cmd” in Notepad or I use Notepad++
- Remove the “myFile.cmd” from the list
- Place cursor on first line and hit “ctrl” + “h” for Replace window prompt.
- In Find what type: “\r\n”
- In Replace with: type: “\r\nsqlcmd –E –n –i” (Update) I now use something like “\r\nsqlcmd -d <databaseName> –E –i” i.e. “\r\nsqlcmd -d Mpi_Data –E –i”
- Hit the button “Replace All”
- This will replace everything but the first line. At the bottom you will have a empty command “sqlcmd –E –n –I” just copy this to the first line and you are set to run your batch command.
- We are always certain all our sql scripts have the “USE [ProductCode]” for each of our “CREATE PROCEDURES”at the top of each .sql so from this point we can just run it on the command line “myFile.cmd” and it will add these stored procedures to the correct database.
Sunday, August 9, 2009
Changing the Diff/Merge Tool in Visual Studio
Compare Settings:
%1 %2 /title1=%6 /title2=%7
Merge Settings:
%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9