Saturday, September 20, 2008

Configaration Manager Missing in Visual Studio

Configaration Manager is what we use to set the build mode(debug or release),some times you might not see the option either in the task bar or in the context menu of the solution.If that is the case you can get that option back by checking on

Tools --> Options --> Projects and Solutions --> Show Advanced Build Configarations.

Subversion SVN Backup - HotCopy Not a folder copy

Subversion hotcopy is tricky, because you have to empty the contents of the destination folder before you run the svnadmin hotcopy command.

To do this I create a console app and run it before the svnadmin command runs.App is really simple and has the following code in it.

''share of the destination folder
Dim folder As String = "\\svnbackupserver\svnreposbackup"
Dim rootFiles() As String = System.IO.Directory.GetFiles(folder)
For Each file In rootFiles
System.IO.File.SetAttributes(file, FileAttributes.Normal)
Dim dr() As String = System.IO.Directory.GetDirectories(folder)
For Each item In dr
Dim str() As String = System.IO.Directory.GetFiles(item)
For Each item1 In str
System.IO.File.SetAttributes(item1, FileAttributes.Normal)
System.IO.Directory.Delete(item, True)
Catch ex As Exception
End Try
End Sub

C:\Batch\SVNBackup.exe svnadmin hotcopy \\svnserver\svnrepo \\svnserverbackup\SvnReposBackup

Subversion Apache Authorization File

Once authentication is done the next step is authorization,which is used to maitain permissions by creating groups or adding individual users to the projects or folders.

#Note: Active Domain accounts require "DomainName\username"
#Note: all usernames are case sensitive and should be created/entered in lowercase

admin = DomainName\svnadmin
managers = DomainName\manager1,DomainName\manager2
inhouse_developers = DomainName\developer1,DomainName\developer2
interns = DomainName\intern1
contracters= contracter1,contracter2,contracter3

# These are the permissions allowed for each PROJECT
# Note "/" assigns permission to the entire repository
# "/Test" assigns permission to only "/Test" project
#inhouse_developers has access to entire repository
#contractors has only access to Test Project
#admin has access to entire repository

@admin = rw
@managers = r
@inhouse_developers= rw

@inhouse_developers= rw
@contracters = rw

Subversion Apache - Using network shared folder for a repository

One of the nicest things Subversion has to offer along with apache is its capability of storing the repository on a netwok share.You should use the following line in the apaches httpd.conf files location block.

SVNPath "//SnvServer/SVNREPO/"


Subversion Apache Windows Authentication and Custom Authentication

Man I cannot tell how much flexibility Subversion with Apache has to offer.One thing we wanted to do is authenticate user against Active Directory if the user has a login otherwise use a encrypted file.

Here is how the configaration of the apache httpd.conf file looks like to acheive the above.


DAV svn
SVNPath E:\SvnRepos
AuthName "Enter username and password"

#Authorization File that has user groups and permissions
AuthzSVNAccessFile "C:\Program Files\Apache Group\Apache2\conf\svn-auth.conf"
AuthType SSPI
SSPIAuthoritative On
SSPIDomain mydomain
SSPIOfferBasic on
SSPIOmitDomain On

# Htpasswd Logins.
AuthType Basic
AuthAuthoritative Off

#passwd file that is generated from htpasswd tool
AuthUserFile "C:\Program Files\Apache Group\Apache2\conf\passwd"
require valid-user

Everything above is self explanatory and the above statements should be in the Location block.

Sunday, September 14, 2008

use XML and OPENXML to perform Data Manipulation : Table Variable as a parameter to stored procedure

There might be times where you want to perform operations on multiple rows with a single call to the database using a stored procedure.But the problem is SQL Server has no table parameter that can take a collection of rows.To solve this problem u can pass all the rows in a string variable, parse the string into columns and rows and perform the operation you want.Sometimes you might endup sending the delimeter in the data that can cause the parsing to break.A cleaner solution is to pass the xml string and use open xml to transform string data into rows.

Following function is used to build the required xml string for the strored procedure.

Private Shared Function BuildCustomerXMLString(ByVal cc As CustomerCollection) As String

Dim ms As New MemoryStreamDim sr As StreamReader

Dim XMLString As String

Dim writer As New XmlTextWriter(ms, System.Text.Encoding.Unicode)

writer.Formatting = Formatting.Indented


For Each lcc As Customers In cc
writer.WriteAttributeString("CustomerID", XmlConvert.ToString(lcc.CustomerID))
writer.WriteAttributeString("CustomerName", lcc.CustomerName)
writer.WriteAttributeString("CustomerEmail", lcc.CustomerEmail)
End If
''End for root


''commit and close the writer

writer.Flush()ms.Position = 0

''create the stream from the Memory Stream

sr = New StreamReader(ms)''Get the string from the stream

XMLString = sr.ReadToEnd()

Return XMLString

End Function


Following strored procedure is used to update the customer information using the openxml.

CREATE PROCEDURE [dbo].[uspUpdateCustomerInfo]
@CustomerInfo varchar(max)
DECLARE @idoc int;
DECLARE @InputTable table (
CustomerID uniqueidentifier
,CustomerName varchar(50)
,CustomerEmail varchar(50)
EXEC sp_xml_preparedocument @idoc OUTPUT, @CustomerInfo;
INSERT @InputTable (
FROM OPENXML (@idoc, '/ROOT/Customer',1)
CustomerID uniqueidentifier
,CustomerName varchar(50)
,CustomerEmail varchar(50)
) c;

CustomerID = it.CustomerID
,CustomerName = it.CustomerName
,CustomerEmail = it.CustomerEmail
FROM Customers c
INNER JOIN @InputTable it ON it.CustomerID = c.CustomerID;

Thursday, August 28, 2008

Custom sorting using t-sql

I had an requirement where rows in a table needs to be sorted in a custom order instead on the column of a table.

Here is how the data in the table looks like.
ex: Customer

ID Name Address
1 a
2 b
3 c
4 SystemAdmin
5 ProgramAdmin
6 d
7 e

This is how the results should look like after sorting

ID Name Address
4 SystemAdmin
5 ProgramAdmin
1 a
2 b
3 c
6 d
7 e

Select ID,Name,Address
From Customer
Order by Replace(Replace(Name,'SystemAdmin','_a'),'ProgramAdmin','_b') Asc

the above t-sql is going to yeild the results wanted, but might not be the best and optimized query in the world.

Wednesday, July 2, 2008

what am I without you

After seeing the title you might be thinking of "I'm all out of love" from Air Supply or Denny's Breakfast Commercial, but I am thinking of my RoboForm that saves me so much time and frustration of typing my details again and again on the web forms.

I use their free edition that can save upto 10 logins, hey its only 29 bucks to upgrade to their pro edition which has no limit how many login you can store and might have some extra stuff that free one dont have. Anyways RoboForm can store all your personnel information name,address,dob,credit cards,email . . . .and even your preferred account id(when you are registering on a new website) and password.Its clever enough when you go to a web form that has all the fields with a click of a button you web page is with what you want to type.

ssssh! , it has encryption built into it to protect your identity.

Tuesday, July 1, 2008

Am I the PROBLEM????????

I don't know if I am the problem or my stupid routers that are interfearing with other wireless devices are!. Moved to a new apartment and started setting up wireless network.Any of my three routers don't want to work how they supposed to work.Upgraded the firmware, change the lan ip to of my dsl modem having the and did many other things but couldn't make them work.

The three routers I bashed my head with are Dlink DI-524, Linksys-BEFW11s4 and Belkin -F5D7230.I don't know if there are any devices in the range interfearing with my routers and causing my bounding with my dsl router with a wire.

Sunday, June 29, 2008

Boy No Wonder Why Audacity Rocks and is in the top 100 Best Freewares

We are so used to the Internet nowadays that we don’t realize how much we need it until there is a disconnect from the outside world.I was in that situation last night.Moved into a new apartment, provider told me it takes about 24 hrs to get the Internet connection.

I had a need to record a phone conversation last night from my Motorola l7.If I had time and right tools I would have made a Cable that connects to the mini usb port of my phone and line in of my computer but unfortunately I didn’t have any of the two.So I had to turn on the speaker on the phone and record the conversation that way. But the stupid neither the Microsoft recorder nor the Movie maker helped me do that.Recorder can records only up to 60 secs and whereas movie maker only reads data from the input video devices.

If I had the Internet connection I would have gone with mp3mp3 recorder, that's my favorite.
Unfortunately I was not, but still had to record.One of my desktop had Audacity installed on the machine, I copied the folder from the program files from my desktop and copied to my laptop where I want to record as my desktops microphone wasn't working.

Copied the files clicked on the .exe I was up and running the recording in less than a minute.Audacity recognized that the software is not installed on my laptop it prompted me to pick a language and few other options.It also supports automatic recovery just in case if something happens to the computer.

Audacity saved my day.

Thursday, May 8, 2008

Main Form and Splash Screen c# windows application

Splash screen in Visual Studio is a greatway to give user the feedback of loading the application.Problem I faced implementing the Splash Screen is main form always used to hide in the task bar.After doing a couple of searches I found out that spash screen delay time is the culprit.

I made the splash screen to show for few seconds than my main form which gives the focus to the main form that avoids the form staying in the task bar.

In Application Events.vb I added the following

Namespace My
' The following events are availble for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication
Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
'Set the splash screen timeout.
Me.MinimumSplashScreenDisplayTime = 1000
Return MyBase.OnInitialize(commandLineArgs)
End Function
'End code paste
End Class
End Namespace

In the form load is the following code

Dim dt As DateTime = DateTime.Now
Me.WindowState = FormWindowState.Normal
Dim timespaninms As Integer = (DateTime.Now - dt).Milliseconds
''Comment or delete the line below once you get the average load time after 5 or 6 runs.
'MessageBox.Show("Time in MilliSeconds : " + timespaninms.ToString)
If (timespaninms < My.Application.MinimumSplashScreenDisplayTime) Then
My.Application.MinimumSplashScreenDisplayTime = timespaninms
My.Application.SaveMySettingsOnExit = True
timespaninms = My.Application.MinimumSplashScreenDisplayTime - timespaninms
End If

Sunday, May 4, 2008

Visual SourceSafe lost the keyboard when removed the bindings

Sometimes if I want to do lot of changes to my project, I always disconnect my netweok cable and make a copy of my project and open the solution.After opening the solution Visual SourceSafe prompts you to work in disconnected mode, permanently remove bindings or manually remove bindings.If you remove the bindings visual studio seems to lost the keyboard you cannot use any keys in the IDE except the Special Keys.I went ahead and change the readonly setting on the folders and everything works fine after that.

Visual Studio you are lost baby!

Saturday, April 5, 2008

AT and T text to voice wow

Yesterday I was searching for a tool to convert some text to voice and found AT&T text to voice online tool on at&t research website.I have used many tools in the past but this one is very close to natural.I am really impressed with the stuff they have done, there is a 300 character limit but type in 300 characters create a voice file do the same for all the text you want and create mp3 for all em and join em using a file joiner. I know this is pain to do but the for the quality of the voice you can take that.

IIS Manager Crashes on Load/Start Windows 7, IIS 7.5

IIS Manager Crashes on Start  Windows 7, IIS 7.5, Power Shell 5.1. Here is the error I got in the event viewer. IISMANAGER_CRASH IIS Ma...