Crystal Reports: Invalid Table Number

Ok, here’s the solution to a problem that I had that took me a while to work out.

This solution isn’t posted anywhere on the internet and the closest to it is ‘I re-installed my PC’.

What I had happening was when I was changing the Location of a Crystal Reports table to change the database details:

foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location = DatabaseName+”.dbo.” + crTable.Location.Substring(crTable.Location.LastIndexOf(”.”) + 1);
}

This final line would error out with an Invalid Table Number. The cause it turns out is not a bad Crystal version or installation, but rather a broken ASPNET user account.

When Crystal runs, it runs in the aspnet_wp.exe process, which runs as ASPNET local user. Somehow when I renamed my computer name, it messed up the SQL server authentication of that user. And re-adding the COMPUTER\ASPNET user to SQL didn’t seem to want to work. It acted exactly like my ASPNET user was not really COMPUTER\ASPNET. Stranger still, my ASPNET webpages did work, just not Crystal.

The solution: I manually deleted my Windows ASPNET user, used “aspnet_regiis -i” to then re-create the user correctly, re-added that user to my SQL Server and then re-booted my PC.

As if by magic, problem solved.

Leave a Comment