Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Saturday, August 15, 2009

Create a Column in Excel with Leading 0s

To create a column in Excel with leading 0s given a column A with values 0,1,..., and 12 character string to create, use this formula on the target column:


= RIGHT("000000000000" & A1,12)

The result will be 000000000000,000000000001,...
Then just use the copy, paste special as values technique mentioned earlier.

Reference: http://www.koozie.org/2004/11/excel_leading_z.html

Concatenate two Excel Columns with a Character or String

To concatenate (or join) two columns A2 and B2 into C2 with a hypen (in this case), use this formula in C2:

=A2&"-"&B2

Then copy the results down the column with click and drag downwards to duplicate the formula on the cell. Finally, copy column C and paste special into the target column as values only.

Reference: http://www.pcmag.com/article2/0,2817,33100,00.asp

How to Create GUID from a String

This is an easy way, but esoteric task, to create a GUID from a string:


Guid g = new Guid(string);

Reference: http://www.devnewsgroups.net/dotnetframework/t2650-convert-string-guid.aspx

Using Vista to Add a User Account to a Group

Here is a helpful description of how to add a user account to a group. Of course you probably need Vista Business or Ultimate.

Reference: Using Vista to Add a User Account to a Group

Tuesday, April 14, 2009

Getting Started With Microsoft Charts

I just ran across a tutorial on getting started with Microsoft Charts for ASP.NET 3.5. The pre-requisite is to download the chart.exe from http://code.msdn.microsoft.com/mschart Specifically, I clicked the "Chart Controls for .NET Framework" link on that page to download MSChart.exe.

Microsoft offered this in response to Googles Charts by buying Dundee's Charts that was for .NET 2.0. Note, this new one is for 3.5.

Tuesday, March 31, 2009

SQL Server 2005 database diagram support objects error

Sql 2005 Database diagram support objects cannot be installed because this database does not have a valid owner...

Solution:
1. Right Click on your database, choose properties
2. Goto the Options Page
3. In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
4. Goto the Files Page
5. Enter "sa" in the owner textbox.
6. Hit OK

Reference: http://geekswithblogs.net/shahed/archive/2007/11/19/116940.aspx

Thursday, March 19, 2009

Incorrect Syntax Near sproc ...

I got this 'incorrect syntax near spoc (stored procedure)' error from the following:

string connectionString = getConnectionString("ConnectionString");
SqlConnection conn = new SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("sproc_aspnet_StocksInLists_RemoveStocksFromList", conn);

try
{
conn.Open();
command.Parameters.AddWithValue("@ListId", ddlList.SelectedValue);
iRes = command.ExecuteNonQuery();
if (iRes < 0) throw new Exception("Error removing stocks from list");
}
The bug fix is to set the command type:

string connectionString = getConnectionString("ConnectionString");
SqlConnection conn = new SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("sproc_aspnet_StocksInLists_RemoveStocksFromList", conn);
command.CommandType = System.Data.CommandType.StoredProcedure;
try
{
conn.Open();
command.Parameters.AddWithValue("@ListId", ddlList.SelectedValue);
iRes = command.ExecuteNonQuery();
if (iRes < 0) throw new Exception("Error removing stocks from list");
}