SQL 2005 Login Not Associated with Trusted Connection

October 20th, 2008

I found this post helpful Login failed … not associated with a trusted SQL server connection

I created a named instance of SQL 2005 and during the install selected Windows Authentication mode only (mainly because I didn’t want to go through the trouble of creating and having to remember another strong password for the sa account). 

 I then created a new database along with a new SQL user account.  However, because I selected only Windows Authentication Mode in the install, I had to go back into the properties of the named instance and under the Security section change the authentication method to SQL Server and Windows Authentication mode.  For good measure I restarted the server.  I then tried to log in with my application without making any other changes and that did the trick. 

 This error message is rather misleading…it would have been great if it would have said something along the lines of SQL Server Authentication is not enabled on this database and/or sql instance.

AdSense/AdManager Performance Affecting Page Load

October 20th, 2008

If you’re incorporating AdSense and AdManager (or even just AdManager without AdSense) directly into your page, the time it takes the page to load might start to increase.  This is because not only is the page loading all the usual stuff, but it has to also wait for the Ad information from Google.  The option I’m using to address this is iFrames.  …it’s really pretty easy.

I put this on the page where the ad will be displayed:

<iframe frameborder=”0″ height=”90px;” width=”728px;” src=”Ads\Leaderboard.htm” mce_src=”Ads\Leaderboard.htm”></iframe>

The htm file looks like this (I’m using AdManager here so this HTML might be specific to integration with AdManager):

<html>
<head>
<script type=”text/javascript” src=”http://partner.googleadservices.com/gampad/google_service.js“>
</script>
<script type=”text/javascript”>
GS_googleAddAdSenseService(”[Your AdSense/AdManager #”);
GS_googleEnableAllServices();
</script>
<script type=”text/javascript”>
GA_googleAddSlot(”[Your AdSense/AdManager #]”, “[Ad Slot Name]”);
</script>
<script type=”text/javascript”>
GA_googleFetchAds();
</script>
</head>
<body style=”margin:0px;”>
<script type=”text/javascript”>
GA_googleFillSlot(”[Ad Slot Name]”);
</script>
</body>
</html>

Transaction Scope and Connection Pooling Issue

July 18th, 2008

So, I was getting an error message like this.  Transaction Scope - The operation could not be performed because OLE DB provider “SQLNCLI” for linked server “XXX_LINKED_SERVER” was unable to begin a distributed transaction. OLE DB provider “SQLNCLI” for linked server ”

In one part of my application I was doing something like this

Database db = DatabaseFactory.CreateDatabase();
using (TransactionScope scope = new TransactionScope())
{
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
…execute local procedures
}
}
scope.Complete();
}

Then later on in the application I’m doing something like this

Database db = DatabaseFactory.CreateDatabase();
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
…execute a stored procedure that hits a linked server (no transactions)
}

Because I am pooling connections, it seems as though an open connection was transaction ready and when it hit the linked server procedure, without DTC enabled, this message was being displayed.  In order to put in a quick fix, I turned connection pooling off; Pooling=false in the connection string.  Another option might be to create a separate connection string for any connection that utilizes transactions.

I found another similar post here, but no answer - http://forums.asp.net/p/1261778/2499763.aspx#2499763

Adding a ToolTip to Windows Form Label

July 16th, 2008

Here’s a helpful article on how to add a tooltip to a label … Add Tooltips for Label

private System.Windows.Forms.ToolTip labelsToolTip;
this.labelsToolTip = new System.Windows.Forms.ToolTip();
this.labelsToolTip.SetToolTip(this.firstLabel, “First Label”);

Windows Form Spellcheck with Microsoft Word

July 14th, 2008

I found a helpful post on MSDN Forums and modified it slightly to fit my needs.  I’m using this code to perform spell checking on all textbox controls within a panel control.  I added a single spell check menu item that, when clicked, loops through those controls and leverages word’s spell checking capabilities to correct any misspelled words.  I then copy the modified text back into the control and save the report when everything is complete.

Add a project reference to Microsoft.Office.Interop.Word

Code:

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();

app.Visible = false;
object template = Missing.Value;
object newTemplate = Missing.Value;
object documentType = Missing.Value;
object visible = true;
object optional = Missing.Value;
object saveChanges = false;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;

foreach (Control control in reportFormPanel.Controls)
{
if (!(control is TextBox))
continue;

Microsoft.Office.Interop.Word._Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);

TextBox textBox = (TextBox) control;

doc1.Words.First.InsertBefore(textBox.Text);
doc1.CheckSpelling(ref optional, ref optional, ref optional, ref optional, ref optional,ref optional,ref optional, ref optional, ref optional, ref optional, ref optional,ref optional);

object first = 0;
object last = doc1.Characters.Count - 1;

textBox.Text = doc1.Range(ref first, ref last).Text;

doc1.Close(ref saveChanges, ref originalFormat, ref routeDocument);
}

app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);

Absolutely Can’t-Live-Without Visual Studio Productivity Tools

June 4th, 2008

It took me about 5 minutes to be convinced that ReSharper and GhostDoc are visual studio add-in’s that I won’t be able to live without. It’s only been a few days since I started utilizing ReSharper and GhostDoc but I can already tell you that I’m saving hours if not days on development activities. With these tools not only are you going to save a tremendous amount of time, but you are going to learn how to write better code at the same time.

I highly recommend these two! Thanks Chris.

Bugzilla Setup on Windows Server 2003 IIS 6.0

May 6th, 2008

After getting everything set up and running, I was getting a Page Cannot be Found (404) error when trying to access the index.cgi page.  Everything seemed to be configured appropriately.  It turns out that I also needed to allow cgi extensions within web service extensions of IIS (Thanks Daden)

I also ran into an issue where I was getting messages that the top of the page similar to “Use of unintialized value in substitution (s///) at …” I found my solution here.  I went back into IIS, hit Configuration under the Virtual Directory tab, and edited the settings for .cgi.  I changed -wT to -XT and the error went away.  The setting ended up being C:\[perl dir]\perl.exe -xC:\[bugzilla dir] -XT “%s” %s

Useful Links:

Installation Instructions

IIS Setup & Configuration

Strong Name - Internals Visible To

March 26th, 2008

In an effort to unit test internal methods, I had to make the internals visible to the test assemblies. 

I edited the AssemblyInfo.cs file of the assembly I needed to make public and added a section like this.

#if TEST
[assembly: InternalsVisibleTo( “Tests.Common, PublicKey=PUBLIC KEY” )]
[assembly: InternalsVisibleTo( “Tests.Unit, PublicKey=PUBLIC KEY” )]
#endif

 I used sn.exe to generate the key for me.  sn.exe -Tp assemblyname.dll

Silverlight Hurdles

February 14th, 2008

With a fresh install of VS 2008, I set out to dirty my hands in my first attempt at Silverlight.

Of course I came to find that trying to create a new Silverlight package out of the box fails on load.  Here’s an article that finally helped me figure out why that was - http://wpfwonderland.wordpress.com/2007/12/06/visual-studio-2008-silverlight-package-load-failure/.   Don’t forget to install the latest SilverLight Tools for VS (Microsoft Silverlight 1.1 Tools Alpha for Visual Studio 2008).

Then I spent the next hour or two trying to figure out what version of silverlight is installed on my computer.  Silverlight.net says that I have the latest version , but what version is that I ask???  To quickly find out the version of Silverlight installed on your computer, go to any silverlight enabled website, right click the silverlight object, and select silverlight properties.  You see, the SilverLight js file examples you find only often reference alpha releases of Silverlight in the code so you need to make sure that your Silverlight.js and createSilverLight.js files are built to work with the version of Silverlight installed on your computer.

I found some helpful silverlight links on Scott Guthries blog - Stott Guthrie’s ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas

Here’s a number of other links that came in handy while attempting to figure this all out …
Embedded Media Playback with Silverlight
How to Make a Media Element Loop Indefinitely
Silverlight Quickstarts
Silverlight Technical Articles
What’s New in Silverlight (1.0 Beta and 1.1 Alpha)?

Silverlight Downloads

Learning Windows Communication Foundation (WCF)

January 31st, 2008

I’ve recently been tasked to a project of developing a WCF web service.  This is new territory for me so I’ve spend a great deal of time researching the subject.  I’m in the middle of development so there’s more to come.  In the meantime I’ve provided a handful of links that have helped me up to this point in time.

Windows Communication Foundation
Basic WCF Programming
ABC’s of WCF
Selecting a Credential Type
WCF Messaging Fundimentals