Friday, July 24, 2009

How to use PingBack on your blog

What is PingBack?
If you link to a site in your blog and then run a PingBack utility it will post a link in the comments of that site to your own site.

Look at this --
link to pingback test page
I posted a link to this website which has PingBack enabled, and then ran a PingBack utility and now there is a comment from my blog with a link back to this post.

Why is this useful?
If your blog is topical readers may be interested in reading what you have to say about the subject, so they'll click on your link. Simply put, it will increase your traffic. It is widely accepted because you are linking to them, so they return the favor by linking to you. You are both helping each other, so it's a mutually beneficial relationship.

Read here for more information on why it's useful.

How to PingBack
I learned how to do this from this site: logofarchiver

Get all the programs/files required
1. Download the latest Python
2. Install Python
3. Download Trackback 'em All. It's the ZIP under Downloads section
4. Extract Trackback 'em All files
4. Download FeedParser. Get the ZIP file
5. Extract FeedParser files to the Trackback 'em All folder where you see ""

Setup a command prompt to point to TrackBack 'em All
1. Get a shortcut for Command Prompt (Start->Program Files->Accessories->Drag Command Prompt to the desktop)
2. Change the Start Folder to the TrackBack 'em All folder where "" is located (Right-click->Properties)

1. Now open up that Command Prompt shortcut. It should be pointed to your TrackBack 'em All folder
Add: -a /rss.xml
Send PingBacks:
It will say all the links it's attempting to process. A lot of sites will not have PingBack enabled. If they do have it enabled it will say "Sending PingBack to..."

To test it out create a new blog post and link to this:
Then run the TrackBack 'em All program. Finally go to that website you just linked to and check if theres a comment at the bottom from your site.

Monday, July 20, 2009

Unable to configure CRM for Outlook because of Authentication error

Step 1: Create a managed password
1. On the client computer open the control panel.
2. Open the User Accounts icon.
3. Click the Advanced tab. (click here if you don't see an Advanced tab)
4. Click Manage Passwords.
5. Click Add.
6. Enter the server name of the CRM server
7. Enter the username as domain\username
8. Enter the password.
9. Click OK, then click Close and then click OK.
NOTE: These steps will only work for client physically connected to the LAN or over a VPN connection.

Step 2: Add CRM website to Trusted Sites
1. On the client open IE, click the Tools menu and then click Internet Options.
2. Click the Security tab.
3. Click the Local Intranet icon.
4. Click the Sites button.
5. Click the Advanced button.
6. Enter the website (add intranet and external address) for access Microsoft CRM and then click the Add button.
7. Click OK 3 times.
8. Close any open IE sessions

Step 3: Map CRM website to the server's IP address
1. Navigate to your host file: (On Win XP) :\WINDOWS\system32\drivers\etc
2. Open file 'hosts' with Notepad
3. Enter in the IP address of your CRM web server, tab, and then the name of the server.
i.e. if your server is on, and the name is CRMServer, put CRMServer

note: These steps were found in various locations from various sources

How to access the Advanced tab of User Account

I was trying to figure out where the Advanced tab in User Accounts (Control Panel -> User Accounts) was. It was missing! I'm on Windows XP Pro logged in as the Admin, so that's a bit odd.

All you need to get to the Advanced tab is the following:
1. Start->Run, type cmd
2. Type 'control userpasswords2'

Now you can see a way more useful user management thing than the standard User Accounts.

How to use GROUP BY and HAVING clause to aggregate rows

The number 1 problem for newbies using SQL is the requirement to think in terms of sets. For someone who primarily uses programming languages, such as Java or C++, they are used to thinking in terms of individual operations.

Example: If you have a list of objects that you need to process you will do this by using a loop, and go through each object in the list.

However in SQL the way to do a loop is by using a cursor. This literally goes through all rows, one row at a time. Problem is SQL is not designed to be used like this, so it's totally inefficient!

In SQL whenever you need to aggregate rows and perform calculations on them as a whole you can use the GROUP BY and HAVING clauses.

So what are these?

GROUP BY: You group by all columns that are not aggregate list. For example, lets say you want to calculate the average age of all people with the same last name.
You would use this:
SELECT LastName, AVG(Age) as [Average Age]
FROM People

And the results would be like:
LastName Average Age
Smith 20
Obama 40
Bush 50

Here's a good guide for additional help:

HAVING: This is used for when you want to only get groups that fit a certain criteria. For example, you want to get a list of all last name's for which the average age is > 20. You would use the following:

SELECT LastName, AVG(Age) as [Average Age] FROM People
HAVING AVG(Age) > 20

Using the previous example's query, the results would be:
LastName Average Age
Obama 40
Bush 50

*Notice how Smith 20 is missing? :)

Access denied to folder when using FileUpload dialog

I had this problem when i was creating a video management system.

Problem: Access denied to a folder that you are trying upload a file to, using FileUpload.

FileUpload has a posted file. When a postback occurs the posted file stream is removed. I had a button called [Upload Video] that was meant to validate the upload. The actual upload operation is done after all the information is input and the [Save] button is hit. So because of this problem i decided to make the [Upload Video] do the upload operation.

Put simply: You need to perform the saving of the file prior to any postback, otherwise the file stream is not there anymore!

How to dynamically retrieve a company's name in Dynamics GP

So I had to build reports for a company and then make it generic so we could resell it to anybody. Well a big problem we had was how to get the company's name on the report without asking them for it. Well here's the trick:

WHERE Dynamics..Sy01500.INTERID = (SELECT db_name())

This works because Dynamics stores the company's database name, which you can reference to get to the company's formal name.

An item disappears from radio button group

I have a radio button group with 4 choices, and I need to add another one. So i went to the RBG's properties and clicked on "Collection" and added
the new choice. I then built and debugged it, and noticed that the choice was NOT there!

So I looked in the behind code (ASP.NET markup) and noticed that the choice was not actually put in the list, but it was appearing in Design Mode.

Whats up with that? Well I couldn't find any explanation for why it happens but all you need to do to fix it is manually add the new item into the RBG:
like this

<asp:RadioButtonList ID="Choices" runat="server">
<asp:ListItem Value="OldChoice">Old Choice</asp:ListItem>
<asp:ListItem Value="NewChoice">New Choice</asp:ListItem>

Sunday, July 19, 2009

How to create dynamic links in a gridview

Whenever you are displaying results for a query you need to allow the user to click on a link that will bring them to an appropriate page. Put this in a GridView and customize to get the results you want:

<asp:TemplateField HeaderText="Subject">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("ID", "~/Page.aspx?id={0}") %>'
Text='<%# Eval("Subject") %>'></asp:HyperLink>

How to create a multivalue array in SQL

I had to figure this out when I was creating reports. The report had to be based on different document types depending on the choices of the individual. So lets say theres 5 different document types. Well a simple query to check all 5 document types would be

SELECT * FROM Table WHERE DocType IN (1, 2, 3, 4, 5). Well now you have a very complicated query to deal with when you have to exclude document types. The simplest way is to save the "IN" string as a multivalue array. I.e. you would use the string "1, 2, 3, 4, 5".

Well here's how you do this:


1. First create a function that's used to parse the parameters can turn it into a
multivalued array

@psCSString VARCHAR(8000)

WHILE LEN(@psCSString) > 0
SET @sTemp = LEFT(@psCSString, ISNULL(NULLIF(CHARINDEX(',', @psCSString) - 1, -1),
SET @psCSString = SUBSTRING(@psCSString,ISNULL(NULLIF(CHARINDEX(',', @psCSString), 0),
LEN(@psCSString)) + 1, LEN(@psCSString))


2. Create the stored procedure that will use the function from step 1.
@sCategoryID VARCHAR(5000)
SELECT * FROM TblJobs WHERE iCategoryID IN (SELECT * FROM UF_CSVToTable(@sCategoryID))

How to upload and play a video (ASP.NET)

So I was given the task of creating a video management system on my work's website. This simply means employees can upload a video, and then allow anybody to view the video.

Notice: This is way more simple than a final version would be, this is just to show the basics of getting it to work.

1. Add the ability to upload video:
public partial class WebUserControl : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)
if (!fileUploadDialog.HasFile) //Check if user has specified file
lblStatus.Text = "Must select a video file to upload";
string virtualFilePath = "~/VideoDirectory/" + fileUploadDialog.FileName;

string physicalFilePath = Path.Combine(Server.MapPath("VideoDirectory"), fileUploadDialog.FileName);

SqlCommand cmd = new SqlCommand();
Guid vidId = Guid.NewGuid();
cmd.CommandText = "INSERT INTO Videos(VideoID, VideoPath) VALUES(@VideoID, @VideoPath)";
cmd.Parameters.AddWithValue("@VideoID", vidId);
cmd.Parameters.AddWithValue("@VideoPath", virtualFilePath);
cmd.Connection = new SqlConnection(YourConnectionString);
lblStatus.Text = "File has been uploaded!";

catch(SqlException se)
//SQL error occured, so delete file in the file system
lblStatus.Text = "A SQL error occured, file has not been uploaded.";

2. Use a GridView to display the list of videos. Dynamically generate links to the video viewing page:
<asp:gridview id="gvVid" runat="server" autogeneratecolumns="False">
<asp:templatefield headertext="Name">
<%# getFileName(Eval("VideoPath").ToString()) %>


<asp:templatefield headertext="Video Link">
<asp:hyperlink navigateurl="" vid="{0}&quot;)">">
ID="HyperLink1" runat="server">[View Video]</asp:hyperlink>

protected void Page_Load(object sender, EventArgs e)

protected string getFileName(string path)
return System.IO.Path.GetFileNameWithoutExtension(path);
protected void btnRefresh_Click(object sender, EventArgs e)
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(YourConnectionString);
cmd.CommandText = "SELECT VideoID, VideoPath FROM Videos";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
gvVid.DataSource = dt;
{ }


3. Setup the behind code for the video viewer page

string vpath = "";

if (Request.QueryString["vid"] != null && new Guid(Request.QueryString["vid"]) != Guid.Empty)
SqlCommand cmd = new SqlCommand("SELECT VideoPath FROM Videos WHERE VideoID = @VideoID");

cmd.Connection = new SqlConnection(YourConnectionString);
cmd.Parameters.AddWithValue("@VideoID", Request.QueryString["vid"]);
vpath = cmd.ExecuteScalar().ToString();

catch { }
if (cmd.Connection.State == ConnectionState.Open)

Label1.Text = vpath;
MediaPlayer1.MediaSource = vpath;

**MediaPlayer1 is from Silverlight. You'll need to download this and include it in your project. Get silverlight here: silverlight sdk download

Now you have the basic setup that will allow you to create your own video management system. Good luck.

A healthy information source

Recently I became interested in getting physically fit and being healthy. Well, where to begin? I started combing websites for useful information that would allow me to get started with my quest for a healthy lifestyle.

I ran into many sites that suggested information that I didn't find that useful. And then I found this site: health blog, which dispenses tips for being healthy, the natural way (aka natural health)! This is quite interesting and different from other sites because 1) The blogger is a genuinely trying to help people out, and 2) the information helps you solve practical health problems using natural remedies, instead of prescription drugs.

So yeah, from now on I'm going to be using this site. After all, I can't keep computers healthy if I can't keep myself healthy :)

How to center your web page content using a div

Go to and try resizing the page. Notice how everything remains centered? Well the trick to using that is by using <div>'s. The way you do this is the following:

1. Insert the following code into a CSS file:
text-align: center;

text-align: left;

2. On your content page insert a <div class="content">

Voila! Your div will now be centered and all it's content will be left aligned :)

How to get XML File Changes to work in InstallShield 10.5

Problem: XML File Changes feature is not properly updating an element's content to a [PROPERTYNAME] changed value. This can be found by navigating to "XML File Changes" -> Click on a node -> click on "Advanced tab"

Workaround: First set the content to "[PROPERTYNAME]" (with qutoation marks), build it, and then remove the quotation marks, and build again.

Note: This is a bug and it's not known why this workaround actually works, but it does.

Calling a function when button is clicked in datagrid

So you have a datagrid that's automatically populated by your data, including dynamically generated links.

For example, you allow people to search for books, and you want them to be able to click on a link to the books that are returned in the search...well you need to dynamically generate the links based on the books ID. etc...

Well sometimes you also need to be able to call a function to do some additional processing when the list is generated. Here's the code necessary to do this:

<asp:TemplateField HeaderText="Video Links" >
<asp:LinkButton OnCommand="lbEdit_Click" ID="lbEdit" CommandName="Edit" CommandArgument='<%# Eval("VideoID").ToString() %>)' runat="server" Text="Edit Video">

In the C# behind code file:
protected void lbEdit_Click(object sender, CommandEventArgs e)
//Pass the contextual info to the next function

How to get your deleted records back in CRM

Have you ever accidentally deactivated or deleted something in CRM that you wish you could get back? well, my coworkers have, so you're in luck :)

First of all, records aren't really deleted right away like you think would happen. They are MARKED for deletion, and then bulk deleted (this is ideal for performance).

Here's what to do:
1. Login to the SQL Server containing your CRM database
2. Find the table that holds your record of interest. For example, if you deleted an Account, you'll want to use the AccountBase table
3. Execute a query to find your record of interest, and then confirm that this is the appropriate record. For example, if you deleted an Account with the name of "Oops Enterprises", search for that
4. Execute the following update:
UPDATE SET DeletionStateCode = 0

Yay! Now if you go into CRM you'll see that your deleted object is still in there!

Disclaimer: Your records are eventually deleted, so you need to act as quickly as possible before they are actually deleted.

How to setup a network printer

If you are using a printer that is capable of network printing, follow these steps to set it up:

1. Plug network cable to Ethernet plug
2. Go to Printers and Faxes
3. Add a printer
4. Local printer, uncheck Plug and Play
5. Add port
6. Add TCP/IP type port and type in the IP of the printer (you should be able to find this within the display screen on the printer, use Menu/Setup and then find network settings)
7. Point to this port
8. Add the appropriate drivers and print a test page

How to speed up CRM for Outlook

Most of my coworkers use the CRM for Outlook client, which basically integrates CRM and Outlook, allowing you to attach emails to entities (i.e. Cases, Accounts) in CRM without having to use CRM itself.

A major problem they were having is that using CRM for Outlook caused their Outlook's performance to decrease. Well here are methods i found that actually helped to increase the speed issues...Good luck!

. Close Outlook
2. Go to:
If XP: C:\Documents and Settings\\Application Data\Microsoft\Outlook
If Vista: C:\\AppData\Roaming\Microsoft\Outlook
Note: These may be hidden so go to any folder and select Tools > Folders Options > View. Check "Show hidden files and folders".
3. Rename outcmd.dat to outcmd.dat.old, and the same thing for outlprnt. (outlprnt may be missing)
4. Start->Run
5. Type regsvr32 OLE32.DLL, hit OK
6. Type regsvr32 INETCOMM.DLL, hit OK
7. Restart Outlook

How to determine if object from database is null (C#)

When you are getting data out of your database you may need to do some type checking. This is important if the field allows null.

For example, if you have an nvarchar(#) that allows Null, you'll want to check if you are getting a Null string so that you can safely set it to "" (empty string) or whatever value you want. This prevents exceptions from being thrown.

Code (ADO.NET C#):

Using one line:
string columnName = reader["columnName"].GetType() == Type.GetType("System.DBNull") ? "" : reader["columnName"].ToString();

Using if, then:
if(reader["columnName"].GetType() == Type.GetType("System.DBNull"))
columnNameVariable = ""; //or whatever value you want to set it to
columnNameVariable = reader["columnName"].ToString();
There was an error in this gadget