Monday, October 19, 2009

Migrating or Moving Microsoft Small Business Accounting (SBA) 2009 to a new Server

I'm not sure what exactly I did to fix my SBA problem, since I tried about 300 things.

The problem was that I wanted to move the database from one server to another, but once it got to the new server I couldn't connect from anywhere except the server itself.

The error message was:
The company could not be opened. Please ensure the SQL Server exists, the service is running and access has been granted.
Like I said, I tried a ton of stuff, but when I finally noticed that it was working, I modified the multi-user SBC file to read:

SERVERNAME\MSSQLSERVER,5356

instead of just SERVERNAME,5356

That's the first and only time I've ever seen a named instance required when you only have one instance running, but it works now.

Tuesday, September 29, 2009

Accessing Custom Profile Properties in DNN (DotNetNuke)

In DNN you can create custom profile properties to add to user profiles. There are all kinds of uses for this, but for the sake of the example, let's say we want to add a property called "FavoriteColor" to the user profile.

Adding the property is easy enough. Go to Admin--> User Accounts, then select Manage Profile Properties from the Edit menu.

Add your new property, and give it a type and a name.

Now, to access the value from your code:
Dim myValue as string
Dim m_objProperties As DotNetNuke.Entities.Profile.ProfilePropertyDefinitionCollection
Dim curUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo()

m_objProperties = curUser.Profile.ProfileProperties
myValue = m_objProperties.GetByName("FavoriteColor").PropertyValue
You probably need to add code to make sure the user is logged in. In this example you could verify that curUser.UserID >=0.

Reference: DNN Message Board

Friday, July 31, 2009

DotNetNuke (DNN) and JavaScript: Referring to Controls by ID

The client ID of a control in ASP.NET is different than the server control name.

Meaning, specifically, that if you name your textbox txt1, ASP.NET (and therefore DNN) will rename it something like DNN_ctr383_mymodule_view_txt1.

That causes issues when you want to refer to a control in a JavaScript on the client side (for instance in the OnClientClick event).

Fortunately, there is an easy way to do this. Server controls have a property called ClientID that you can access easily.

For example:

var myObject = document.getElementById("<%= txt1.ClientID %>");

Wednesday, June 24, 2009

ASP.NET AJAX Color Picker Control Breaks to Second Line

I added the new ASP.NET AJAX ColorPicker control to a project.

I also added the little colorpicker image and the div to show the color that has been selected.

By default, when you add those controls, the colorpicker will break to a second line. To fix it, add style="float:left" to the textbox properties.

The Situation:
You have an ASP.NET AJAX Color Picker control on your page, and the color picker control breaks onto a second line.

The Solution:
Add style="float:left" to the textbox properties

Possible Google Searches (ignore this part- it's used to try to help Google find this page):
  • ASP.NET controls break second line
  • AJAX Color Picker controls won't stay on same line
  • VB.NET controls line break

DNN SQL Window: Script Must Include Extra Line Breaks At the End

I had a very frustrating problem the other day. I had a SQL script that I was trying to run in the DotNetNuke (DNN) SQL Window on the Host Menu.

It kept erroring in an odd spot, and I couldn't figure it out.

Well, it turns out that you need to add an extra line break after the end of your code. That's probably why the template has an extra comment block at the end- which I erased for some reason.

Note: This has been fixed in DNN 5.0

In my case, the error was as below:
System.Data.SqlClient.SqlException: Incorrect syntax near 'GO'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions

The Situation:
You are trying to run a script through the DNN SQL Window from the Host Menu. The script seems to error for no particular reason. The script will run through SQL Management Studio.

The Solution:
Add a few extra line returns to the end of your script.

Possible Google Searches (ignore this part- it's used to try to help Google find this page):
  • DNN SQL Script won't run
  • DotNetNuke SQL Script Errors on Go
  • DNN SQL Script Incorrect syntax near 'GO'

DNN SQLDataProvider Files Must Be Encoded as UTF-8

When writing a DotNetNuke module, the script file that creates the database objects is called the DataProvider file. This file must be saved with UTF-8 encoding.

If not, you may get an error on install.

The Situation:
Your SQL script will run in the SQL window under the Host menu, but fails when you try to install the module. You may specifically get an error anywhere where you use a '+' sign in the code.

The Solution:
Open your SQLDataProvider file and resave it with UTF-8 encoding.

Possible Google Searches (ignore this part- it's used to try to help Google find this page):
  • DNN SQL Script fails on install
  • Error while installing SQLDataProvider DotNetNuke
  • DNN Script Runs in SQL Window Fails on Install

The Inaugural Post

I am not the world's best programmer. Far from it.

Most of the time when I encounter an issue while programming I head off to Google and the problem is solved in just a few clicks.

Sometimes that is not the case.

So, in the times where I actually have to do work to solve my problems, I'll write about them and add the solution here. That way, if you, the Googling public, have the same problem, maybe I'll save you a few minutes.

My little way of giving back.