My blog has moved!

Visit http://blog.adamroderick.com/ and update your bookmarks.

Friday, July 24, 2009

Resolved: Failed to connect to database server or the database name does not exist

In the SharePoint configuration wizard, we were receiving the error: Failed to connect to database server or the database name does not exist. This seems to indicate that the database server name is wrong, or DNS is messed up or something. It probably means that.

We also found it means the user account running the installation does not have correct permissions. The account must have SQL log in rights, db creator, and security admin rights.

Labels:

Wednesday, July 22, 2009

Easily Fix your SPWebConfigModification Mistakes

The problem with SPWebConfigModification is that it ACTUALLY modifies your web.config. So if you are relying on a Feature to apply and remove your SPWebConfigModifications, that's a problem when you put in a bad modification. Here is a code block to remove the errored web config problem.

1. Create a new C# console application
2. Paste this code
3. Replace "{24D97BF4-E67E-44ae-92E1-39E0029B61FE}" with the .Owner value you supplied
4. Replace "SharePoint - 8083" with the friendly name of your web application, which can be found in Central Admin's web application list.
5. Run and you are done.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using System.Collections.ObjectModel;

namespace AdamCleanupWebConfigModification
{
class Program
{
// matches the ID in the feature.xml for this feature
private const string FEATURE_ID = "{24D97BF4-E67E-44ae-92E1-39E0029B61FE}";

static void Main(string[] args)
{
SPWebService svc = SPWebService.ContentService;
SPWebApplication webApp = svc.WebApplications["SharePoint - 8083"];
Collection<SPWebConfigModification> collection = webApp.WebConfigModifications;

int iStartCount = collection.Count;

// Remove any modifications that were originally created by the owner.
for (int c = iStartCount - 1; c >= 0; c--)
{
SPWebConfigModification configMod = collection[c];

if (configMod.Owner == FEATURE_ID)
collection.Remove(configMod);
}

// Apply changes only if any items were removed.
if (iStartCount > collection.Count)
{
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
webApp.Update();

Console.WriteLine("Removed " + (iStartCount - collection.Count));

}

Console.WriteLine("Press any key to exit..");
Console.ReadKey();

}
}
}

Wednesday, July 8, 2009

Get Current Page Name Using JavaScript

Quick function to return only the current page name, using JavaScript:


function CurrentPageName() {
return document.location.href.substring(
document.location.href.length
, document.location.href.lastIndexOf('/') + 1
);
}

Labels:

Monday, July 6, 2009

SharePoint Search Results Page for Unathenticated Users

We created a custom search results page for a public-facing web site built on WSS 3.0. The search results page and its site collection were correctly configured for anonymous access, but a search was redirecting anonymous users to the login page. The answer was to remove the Inherits tag from the Page directive at the top of the search results page.

Before:



After:


This post led me to the answer:
http://blogs.objectsharp.com/cs/blogs/max/archive/2008/02/20/sharepoint-search-and-anonymous-users.aspx