I recently needed to parse a line of text which represents a stored procedure call to a database.
The format is
databaseName#storedProcedureName @parameterName=parameterValue

in .Net I used the named groups in my regular expression to get the parts:

^(?<database>[a-z]+)#(?<sproc>[a-z_0-9]+)( (?<parametername>@[a-z_0-9]+)=(?<parametervalue>[a-z_0-9']+))?

Database and stored procedure name are mandatory, then optionally separated by a space a single parameter.


   RegexOptions options = RegexOptions.IgnoreCase;
Regex regex = new Regex(@"^(?[a-z]+)#(?[a-z_0-9]+)( (?@[a-z_0-9]+)=(?[a-z_0-9']+))?", options);

Match match = regex.Match(sprocCall);

if (match.Groups.Count == 6)
{
// we always expect six groups
// if not the string format was not correct
string database = match.Groups["database"].Value;
string sprocName = match.Groups["sproc"].Value;
string parameterName = match.Groups["parametername"].Value.Trim();
string parameterValue = match.Groups["parametervalue"].Value.Trim();
// use the components to make a database call
}


 
Categories: ASP.Net

I was testing Cardspace which comes with IE7, .Net Framework 3 or Windows Vista and while selecting a card the "Windows Cardspace" application hung. There is no way to kill it using Task Manager because your desktop and all other processes are inaccessible when using this tool.
If your computer is on a network, you can kill it remotely:

Open a command line and type
psexec \\computername -u username - p password cmd.exe

Provide a username and password for an admin user on the remote machine.

You can download psexec for free at www.sysinternals.com

You now have a command line running on the remote machine, type:

taskkill /F /IM icardagt.exe


This should kill it, you can then type exit to close your remote session.
 
Categories: IT Pro