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.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.


  1. Nathan Freeman-Smith said,

    May 19, 2010 @ 4:38 pm

    Hi, thanks for the information in your post. Im getting the error message you have described and your fix has worked for me before. Im getting the error again on another production server but the problem is the SQL server instance is on another machine so i cant add the ASPNET user to the SQL service instance as you cant add a local user from another machine!

    do you know if i can specify the user Crystal reports is using to access the database? or can you think of another way i can get around this!?

    Im using similar code to yours above to set the connection info to the new database so im pretty sure its not a code problem as it has worked on a number of other servers.

    Best regards,


  2. 42 said,

    May 19, 2010 @ 10:14 pm

    I think that you have 2 options if the SQL is located on a different server: Use ADS and create a domain account and authorize that user, or setup a SQL Server user and use SQL authentication rather than Integrated Services.

  3. Srinivas M. P. said,

    November 29, 2011 @ 8:31 pm

    Thanks I resolved my issue with following code

    Dim crrpt As New crrept
    Dim cninfo As New ConnectionInfo
    Dim tabloginfo As New TableLogOnInfo
    Dim crtable As Table
    Dim crtables As Tables

    With cninfo
    .ServerName = “orcl”
    .DatabaseName = “”
    .UserID = “myuserid”
    .Password = “mypassword”
    End With

    crrpt.SetParameterValue(“VI_TABLEID”, “GSCH0000000000001144″)

    crtables = crrpt.Database.Tables

    For Each crtable In crtables
    tabloginfo = crtable.LogOnInfo
    tabloginfo.ConnectionInfo = cninfo
    crtable.Location = “MYUSERID.PKG_TEMP.” + crtable.Location.Substring(crtable.Location.LastIndexOf(“.”) + 1)
    Next crtable

    With crView
    .ReportSource = crrpt
    End With

RSS feed for comments on this post · TrackBack URI

Leave a Comment