Monday, December 28, 2009

selectCheckboxes and commandbuttons in Sales Force

Through a lot of trial and error I discovered that the use of selectCheckboxes in Apex code built for disabled all command buttons on the page from executing their code, even though they still posted back to the server.

It was a very odd thing and was easily fixed by changing to selectOptions which is what I needed instead of checkboxes anyway. I am hoping that I had some sort of error in my code that caused the issue, I am sure that others have used selectCheckboxes just fine before.

My guess is that some sort of syntactical error that Eclipse didn't catch is what caused the issue, however since it is gone now I do not plan on digging further into the matter.

Starting Classes

I have finally started classes in AIT for the MOS 25S.
So far we have crammed through basic electronics which I got 100% in.
Next we will be learning some of the more specialized equipment.

Wednesday, November 4, 2009

Free faxing with Skype

I discovered a wonderful little add-on to skype that allows you to fax with your computer. For infrequent faxers it is free, and there are paid options for those who fax a lot.

Tuesday, November 3, 2009

Internet Access

The laptop that my wife mailed me finally arrived with all the required amenities. I am slowly starting to catch up on my online activities again. I really missed having a computer and an online connection.

I am looking forward to being rejoined with my family during Christmas vacation.

Saturday, October 24, 2009

After Basic

Well so far AIT has been mildly dissapointing. They are so overbooked with recruits that we are put on waiting lists for months.

I am able to talk to my wife each day on the cell phone which really helps. She has shipped me a laptop which should arrive in about a week which we should be able to do video chat on, that will be nice. We are hoping to have her move down here right after Christmas vacation.

Friday, October 16, 2009

Graduating Basic

Well basic was definitely an experience. Physically it wasn't too much of a challenge given my country upbringing; but I missed my family a lot and wasn't allowed hardly any contact with them. I am looking forward to AIT with apprehension, we'll see how much freedom I have, I'm hoping for the best and planning for the worst. I really miss computers and hope I have access to them both for programming and contacting my family.

I took this photo for my wife, it's not my standard uniform, but I really like having something I can go on a nice date in now.

Monday, July 13, 2009

Invalid use of side-effecting or time-dependent operator in 'UPDATE' within a function.

I have run into a very interesting and very frustrating problem with Sql Server.
So far my experimenting points to a bug in sql server, though I wish it was something I was doing wrong.

I have created a scalar-valued function that uses a table variable. According to microsoft's msdn and several other sites doing inserts, updates, and deletes on local table variables in user functions is very valid.

In my case I was able to get Inserts and Deletes to work, but am having all sorts of issues with the Update statement. I copied microsofts example one and that executed fine, so then I started replacing pieces of their code with my own and saving/executing until it was a duplicate of my original function. At this point I assumed something must have been cached incorrectly in my original query window.

However, I needed to add a second update statement to the function and while the first one still works the second one won't take. So after messing with it for a bit I once again executed the microsoft example and bit by bit copied each piece of my sproc over replacing their code; and what do you know it worked again.

The only difference I can see is that their update statements are inside of a While loop, so it is still a bug in sql server, but I might be getting a little closer to a better work around.

Update: Looks like it might have been my problem after all, which is wonderful. I was using square brackets around my table variables; on a co-workers suggestion I removed those and my queries started working.

I'm guessing that all I was doing before was figuring out a way to bypass the query parser as can often happen in large stored procedures.

Wednesday, June 24, 2009

salesforce insufficient privileges on custom page

I recently created a new custom apex page in SalesForce. It worked fine as an administrator but regular users were unable to find it.
All of the solutions I found assumed someone was pretty familiar with navigating the SFDC admin area so I figured I would give the path where the answer is located.

The page that helped me the most is here.

  1. Login as an administrator
  2. Click on the 'Setup' link on the left of the upper right hand side
  3. Under 'Administration Setup' in the left hand column, expand the 'Manage Users' list
  4. Click on 'Profiles'
  5. Click on the NAME of the profile you want to give permissions to ( under the Users area you can see what profile your users are assigned to )
  6. Scroll to the bottom of the page
  7. Click on the 'Edit' button for the 'Enabled Apex Class Access' area
  8. Move your new class into the enabled list and click the 'Save' button
  9. Scroll to the bottom of the page again.
  10. Click on the 'Edit' button for the 'Enabled Visualforce Page Access' area
  11. Move your new page into the enabled list and click the 'Save' button

That should be it, anyone in that profile should now be able to see the new page.

Wednesday, June 17, 2009

Cross Apply Incorrect syntax near '.'

I recently ran into an issue that had me puzzled for a bit.
I was using the new Cross Apply functionality in SQL 2005 and was getting the error:

Incorrect syntax near '.'

I checked and rechecked my syntax but couldn't figure out what I had done wrong.
After doing some googling I came accross this sqlteam post in which another poor guy had worked through the same issue.
He ended up figuring out that Cross Apply didn't work when the database was set to sql 2000 compatibility. It makes sense, though it might have been nice to get a more clear error message.

Armed with that information I looked up the code to change the db compatibility level, and what do you know my problem was solved.

Here is the code copied from the link above:
----SQL Server 2005 database compatible level to SQL Server 2000
EXEC sp_dbcmptlevel AdventureWorks, 80;
----SQL Server 2000 database compatible level to SQL Server 2005
EXEC sp_dbcmptlevel AdventureWorks, 90;

Monday, June 8, 2009

Colorado Technical University

I was recently reading on and discovered that Colorado Technical University was one of their recommended colledges.
It seemed they favored CTU because the college not only had higher education courses and has a great distance educational program but also because the school takes special care to tailor itself to the service man/woman's needs. For example they allow the service member to put their education on temporary hold if they get deployed.

Getting such praise from the military is great for me since that just happens to be the college I graduated from. Now that I have joined the U.S. Army, when I want to continue my education I won't have any issue transfering education since they already have all my records.

Web Resource but no Embedded Resource

I was having a major problem trying to get an embedded javascript file registered.
The issue started because I was trying to port over Raj Kaimal's ( ) GridView client side reordering extender to the Data Grid. Since both controls are very similar the work wasn't difficult, however I was getting hung up trying to stick the .js file in my backend dll.

Searching google it seemed as though a lot of people got hung up in this area. I finally stumbed on Lee's post which directed me to Damian's blog

While niether of those posts directly solved my issue, Damian gave me the idea of using a reflector to see what the .NET view of my dll looked like. From that and a little luck I discovered that the proper syntax was:
[assembly: System.Web.UI.WebResource("[default namespace].[folder].[file name].js", "text/javascript")]

then for the script reference:
new ScriptReference("[default namespace].[folder].[file name].js", "[assembly name]");

most people keep the default namespace and the assembly name the same which makes things simpler but fosters a lot of confusion as to what the various parameters are really looking for.

Wednesday, March 25, 2009

T-Sql trigger doesn't always work.

I'm having a rather odd problem.  A trigger I wrote for database Inserts seems to work about 99 percent of the time, but periodically some records will get inserted that the trigger never fires for.  Or rather that the data the trigger is suppose to create is never created.

It's a rather odd delima, if I can figure it out I will try and put the answer here.  In the meantime, if anyone else has experienced this I wouldn't mind hearing about it.

Ok I figured out the answer with a little help from Google.
turns out that in SQL Server a trigger fires once per set of operation as opposed to once per affected row.
so for a standard insert statement the trigger works fine, but if the insert statement has more than one record it is inserting then the trigger will only be fired once.  Good news is that the "inserted" table contains all the records that were inserted, not just one; so you still have access to all the records, you just get them in batch form instead of individually.

Monday, March 2, 2009

Unwanted space between li elements in IE

I ran into an old problem today... a problem where some extra white space was appearing between items in a list.
In this particular case it was only appearing below list elements in an ul where the li contained an image.
Caused the problem:
<li><img src="submenu.gif" /></li>
<li>Contact Us</li>

Fixed the problem:
<li><img src="submenu.gif" />& nbsp;</li>
<li>Contact Us</li>

To fix the issue I ended up manually adding a space with the html code & nbsp;
I recall this issue occuring with some floated divs in IE6 as well, though this time I was having the issue with IE7.

It's a really odd fix to a bug in IE7, but it does seem to work and doesn't seem to cause adverse affects in other browsers.

Wednesday, February 18, 2009

Getting and Setting cookies

I was recently having a lot of trouble trying to set and read a cookie in  I discovered that my big issue was not correctly using the Request and Response objects.  The Request object is only used for retrieving a cookie, while the Response object is only used for creating a cookie.

Another little anomaly I found.  Apparently the client doesn't send the experation date of a cookie when it sends the cookie to the server.  So, in when retrieving a cooky the experation date will always be MinDate even if the date is set correctly.

    HttpRequest oRequest = System.Web.HttpContext.Current.Request;
    HttpResponse oResponse = System.Web.HttpContext.Current.Response;

      HttpCookie oCookie = oRequest.Cookies[ConfigurationManager.AppSettings["anonUserCookie"]];
      if (oCookie == null) oCookie = new HttpCookie(ConfigurationManager.AppSettings["anonUserCookie"], Guid.NewGuid().ToString());
      oCookie.Expires = DateTime.UtcNow.AddMonths(1);

Monday, February 16, 2009

IE7 div centering with margin auto

I've been having some problems getting a div to center on a webpage.  All the websites I have visited said the fix was easy and gave me various forms of this as a solution:

<div style="text-align:center;">
<div style="text-align:left;">
Content goes here.

However, no matter what I put in my stylesheet I couldn't get it to work.  Turns out this fix has to be applied inline.  Putting it in a stylesheet doesn't work.  Once I got that figured out and grumbled for a bit everything worked great.

Tuesday, January 20, 2009

OleDbConnection.GetSchema MS Access list of Tables, Columns, Key columns

I have submitted a couple of community content pieces of code here.

They give details on how to use the ole getschema method to retrieves the schema from an access database to get tables, columns, or key columns.

Thursday, January 15, 2009

NUnit error - Could not load type 'custom.namespace' from assembly 'System.Web...

I was recently having some issues using NUnit to test my code when the code was using the .net membership profile provider.  Scott Davis summed it up nicely:

I've implemented it easily in my site and it works great, but have you been able to unit test it?  On my first attempt, the inherited "Create" method returned a DefaultProfile object, which caused a casting failure.  I figured out that the Unit Tests were not using the web.config file to see the custom Profile Provider I configured, then I figured out you need to copy the web.config to the unit test project, and rename it to app.config.  However now I get the error.  

"Test method TestMyProject.UserControllerTest.CreateNewUserTest threw exception:  System.TypeLoadException: Could not load type 'MyRootNamespace.Profile.UserProfile' from assembly 'System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.."

I don't know why it is not looking the DLL that contains my custom "UserProfile" class.  Any ideas?  It works in my website, but not in the Unit Test.  The UnitTest project references the project containing the Profile class.  I'm using VS2008 built-in Unit Testing.

A little further down I found a link to a forum where the answer was eventually discovered from here and explained a little further:
My config file was something like this:

<?xml version="1.0" encoding="utf-8" ?>
    <add name="MeanWormConnectionString" connectionString="Server=localhost;Database=MeanWormDB;Trusted_Connection=true"/>


    <membership defaultProvider="MeanWormMembershipProvider">
        <remove name="AspNetSqlMembershipProvider"/>
          <add applicationName="MeanWorm" requiresQuestionAndAnswer="false"
            requiresUniqueEmail="true" minRequiredNonalphanumericCharacters="0"
            enablePasswordReset="true" passwordFormat="Hashed" connectionStringName="MeanWormConnectionString"
            name="MeanWormMembershipProvider" type="MeanWorm.Domain.Providers.MeanWormMembershipProvider" />


 His config file was this:


<?xml version="1.0" encoding="utf-8" ?>
    <add name="MeanWormConnectionString" connectionString="Server=localhost;Database=MeanWormDB;Trusted_Connection=true"/>


    <membership defaultProvider="MeanWormMembershipProvider">
        <remove name="AspNetSqlMembershipProvider"/>
          <add applicationName="MeanWorm" requiresQuestionAndAnswer="false"
            requiresUniqueEmail="true" minRequiredNonalphanumericCharacters="0"
            enablePasswordReset="true" passwordFormat="Hashed" connectionStringName="MeanWormConnectionString"
            name="MeanWormMembershipProvider" type="MeanWorm.Domain.Providers.MeanWormMembershipProvider,MeanWorm.Domain" />



Can you spot the difference? It's in the "type" attribute of the add provider tag. If you have a custom provider and do not specify the partial assembly name to find the class in, nunit flips out and tries to load the class from the default assembly, which is System.Web.dll.

If you want more information on how the type attribute works check out this post.

Wednesday, January 14, 2009

NUnit: Could not load file or assembly 'Microsoft.Practices.ObjectBuilder

I use NUnit for testing and was getting this error when using one of the Microsoft app blocks to write stuff to the event log.
Turns out the answer was simple, the Microsoft.Practices.ObjectBuilder.dll simply didn't get copied locally in the test project even though it was set to copy local. I manually copied in the dll and it works great.

Tuesday, January 13, 2009

Create Strong Name Key - Access Denied Error

I recently ran into this error when trying to generate a new strong name key file.

I found the solution here:
I had to give my user account access to the key container in C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys. It turns out, even administrator rights were disabled on my machine! I am not sure if this was the default installation (I rebuilt the machine a few weeks ago) or if this is modified when I install WinFX, or if when I granted ASP.NET and NETWORK SERVICE access it somehow lost the inherited permissions that were granted when I installed the OS. In any case, at least it seems predictable, you need access to the key store in order to generate keys, makes sense!

Monday, January 12, 2009

Copy and Paste from Excel to MS Access says corrupt clipboard

I was trying to copy a massive amount of information from MS Excel 2007 to MS Access 2007.

After going through all the standard troubleshooting like rebooting and making sure all versions were compatible, I mentioned the issue to my co-worker.  Fortunately for me my co-worker had already experience and spent time figuring out the issue; when I heard what the problem was I was glad he was the one who did the leg work figuring it out.  I didn't do that much work with Excel and Access so I wasn't sure when the problem had begun.

Turns out a relatively recent Microsoft Excel security update ( KB958437)  was the culprit.  As soon as I got that uninstalled copy and paste between the two apps started working again.

Add or Remove Programs list not populating

I spent several days trying to figure out why my Add or Remove Programs list no longer populated.  It would just sit there saying populating, but not actually displaying any programs.

Finally I happened accross this thread, where someone was talking about an extra drive of their causing problems.  Turns out I had an external hard drive that was corrupted, as soon as I turned it off the list started working again.

Friday, January 9, 2009

Using the Data Link Properties wizard in .NET code

I had a really hard time finding an example for this code so I decided to blog about it.

With .NET and Microsoft's dedication to documentation in the last couple of years I have really gotten spoiled.  It is pretty rare that I actually dig into .dll's anymore trying to find some obscure functions and how to use them.  These days if I can't find code examples using the Google search engine for something I want to do I will often just find another way around the problem, it just isn't worth spending time trying to dig into the lower levels for a very high level application.  ( Google Chrome is one exception to this, thanks Google for digging for the extra speed, I love it. )

In this case I spent a few minutes searching for a connection string builder.  I didn't find one so I started to role my own.  After a couple of hours of that and realising just how many options there are I decided to try searching again.  I knew one existed, Microsoft uses it in all their apps it seems, just had to find where it was and how to call it.

I found this guy:
who had essencially made a wrapper around what I was looking for, but there was no source code.  However the fact he did it reinforced my certainty that I would find what I wanted.

Next I ran into Elisabeth who gave me the big break with source code and everything:
[quote source="Elisabeth"]
using MSDASC;
using ADODB;

private string BuildConnectionString()
string strConnString = "";
object _con = null;
MSDASC.DataLinks _link = new MSDASC.DataLinks();
_con = _link.PromptNew();
if (_con == null) return string.Empty;
strConnString = ((ADODB.Connection)_con).ConnectionString;
return strConnString;

I did end up having to go to her source ( glad she linked to it ) to get the pretty names of the .dll's that needed to be referenced:
Microsoft ActiveX Data Objects 2.8 Library
Microsoft OLEDB Service Component 1.0 Type Library