Archive for January, 2007
Retrieving Value from a DataSet

In the continued spirit of posting whenever I answer a question of mine, here’s a simple snippet of C# code that retrieves a value directly from a dataset.

myVar = myDataSet.Tables[0].Rows[0]["myColumnName"];

Note that the string name can replace the numeric indexes used to more accurately identify a table.

Formatting Strings in C#

This article provides a great overview for formatting strings in C#. As I have been dabbling with a new GUI for my database, I’ve been having fits with formatting certain types of strings. This site helped me find my way…

 String Formatting in C#

Of particular help were these examples:

String.Format(”{0:$#,##0.00;($#,##0.00);Zero}”, value);

This will output “$1,240.00″ if passed 1243.50. It will output the same format but in parentheses if the number is negative, and will output the string “Zero” if the number is zero.

String.Format(”{0:(###) ###-####}”, 8005551212);

This will output “(800) 555-1212″.

If you have any questions about string formatting, or pretty much anything related, drop by the Forum and ask it there. It’s an easier place to talk than in the comments section here.

Happy Coding!

Creating single instances of MDI Children

I needed a way to create a single instance of an MDI Child form within my MDIContainer form. After doing some research, I found the following code at CodeProject that did just the trick in a few lines of code. This will stop those pesky QA guys from chewing up all the system memory from opening hundreds of instances of my MDI Children.

Singleton Theory of Forms [@ CodeProject]

Happy Coding!

Chuck Norris Commentaries

Well, had I not read it myself, I wouldn’t have believed it… Chuck Norris, of roundhouse kick fame, has his on commentary site at WND.com.

Chuck Norris Articles [@ WND.COM]

Granted, I haven’t read all of the articles, so I can’t speak to whether his writing skills match up to his roundhouse skills, but it is still rather interesting, in my opinion. So, if you like all things Norris, then by all means give this site a shot.

Concatenating Strings In QTP

Today’s tech post is in response to a surprising amount of queries asking how to concatenate strings in QuickTest Pro.

First, it is important to remember that QuickTest Pro scripts are written using VBScript. With that in mind, you can investigate many corners of the internet for sample code and examples of VBScript code. Using the simple Google query returns a host of good resources: VBScript Google Search.

Second, let’s tackle to concatenation issue. In order to concatenate, or add, strings together, you must use the + operator.

‘ Example
Dim strTemp
strTemp = “I am a ” + “little teapot.”
MsgBox(strTemp)
‘ Results: “I am a little teapot.”

This next example takes two variables and concatenates them.

‘ Example
Dim strResults
Dim strTemp1
Dim strTemp2
strTemp1 = “Who let the ”
strTemp2 = “dogs out?”
strResults = strTemp1 + strTemp2
MsgBox(strTemp)
‘ Results: “Who let the dogs out?”

Hopes this tidbit of information helps you out.

Introduction to Performance, Load, and Stress Testing

In doing some research for an upcoming workshop on Performance, Load, and Stress testing that I will be hosting, I came across this article. This article will provide those that are interested with a solid primer into the world of PLS testing. Written with an agile viewpoint, the information should be useful to all testers.

Performance vs. Load vs. Stress Testing [@ AgileTesting.blogspot.com]

QA techies - read this article!

Perhaps there is hope for my own nation after all…

An astute reader passed this article along to me:

Magic Sealand : FOR SALE!

Apparently, the abandoned sea platform built during WWII had been “taken over” by the Family Roy; which then proclaimed itself a sovereign nation. After battles with the UK and several skirmishes with some naughty German businessmen, Prince Roy gained sovereignty over Sealand. Now, the micronation is up for transfer for $977 million dollars.

For more information, visit the Official Site for the Nation of Sealand.

I’m going to consider finding some arcane structure in the middle of nowhere and then finally proclaiming myself sovereign overlord of Xerotopialandiaworld.

VIVA LA SEALAND!

Uploading a file to your .NET Web Application

I have been working on a skunk works project at my office for the past few days and have been struggling with one small detail — uploading a file to a specific folder within my project path. I wanted to store the file in a relative path, in case I had to move the application to a different server. While this may be a common thing for many code ninjas, I’m relatively new to this and, as such, am excited at my discovery. I’ve found the Request.PhysicalApplicationPath HTTP attribute contains the physical application of the running application, which means I can determine my “relative” filepath.

Below is a helper function I have that takes an HTTP Encoded file from an ASP .NET FileUpload (FileUpload1) control, determines my “relative” file path, saves the (or overwrites an existing) file on the web server, and then returns a string containing the physical path to the file on the server.

string SaveFile(HttpPostedFile file)
{
// Save the uploaded file to an “Results” directory that already exists in the file system of the
// currently executing ASP.NET application. Creating an “Results” directory isolates uploaded
// files in a separate directory. This helps prevent users from overwriting existing application files by
// uploading files with names like “Web.config”.
string saveDir = @”\Results\”;

// Get the physical file system path for the currently
// executing application.
string appPath = Request.PhysicalApplicationPath;

// Specify the path to save the uploaded file to.
string savePath = appPath + saveDir + Server.HtmlEncode(FileUpload1.FileName);

// Call the SaveAs method to save the uploaded
// file to the specified directory.
FileUpload1.SaveAs(savePath);

return (savePath);
}

It’s amazing what you can find when you spend time researching the MSDN library for assistance.

Final Fantasy Fan parody

I can’t speak to the quality, or humor, firsthand, but apparently this is worth a watch. When I get home, I’ll give this a watch. However, it looks like it has been made by college students with an extreme amount of time on their hands, which is usually a recipe for comic gold.

College Saga

For those who’ve made the typical New Year’s Resolution

If you are like me, and the throngs of other people, who just days ago dedicated themselves to shedding unwanted poundage, here’s a story for you - care of MoneyCentral at MSN.

Just last year, I had an incident with my local gymnasium. The gym was fine, but, as one would expect, I didn’t go as much as I wanted to, so I decided to get out at the end of my contract. Who knew that this would take nothing short than an act of Congress to get done. Finally, after months of waiting for “customer service”, listening to managers and supervisors who have “my best interests in mind,” and hearing a service rep actually say they were screwing me out of my money due to a technicality; I was able to cancel my contract. Due to potential libel issues, I shall not name the gym or their mob-like management company.

What I do want to encourage you to do is read this article that I just came across from MoneyCentral. They give you 10 things to look out for at your gym, including the one point I CANNOT stress enough: READ THE ENTIRE CONTRACT IN FULL RESISTING ANY PRESSURE FROM THE SALESPERSON.

Anyway, here’s the link: http://articles.moneycentral.msn.com/SavingandDebt/ConsumerActionGuide/10ThingsYourGymWontTellYou.aspx

Happy New Year to you all!