Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

Linq NullReferenceException on Where Clause

Had a strange error when running a similar query taking data from SQL Server:-

 var returnData = from selectedData in dataTable.AsEnumerable()

 where selectedData.Field<string>("ProductCategory").Trim().ToUpper() == all about abortion "CAT1"

 select selectedData

 

Error was:-

NullReferenceException abortion pill info was unhandled - Object reference not set to an instance of an object

And in debugger it was pointing to the where clause.  After lots of looking around it was because the field "ProductCategory" being returned from SQL Server was returning some nulls in the data.

The Fix:-

Use the ?? operator (see http://msdn.microsoft.com/en-us/library/ms173224.aspx)

var returnData = from selectedData in dataTable.AsEnumerable()

where (selectedData.Field<string>("ProductCategory") ?? "").Trim().ToUpper() == "CAT1"

select selectedData

 

SharePoint 2010 Visual Web Parts - Specified path, file name, or both are too long Error

Whilst trying to deploy a newly created SharePoint 2010 Visual Web Part I came across this lovely error:-

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

It abortion pill info is a bit of a strange error as I'm not sure why having a long name would create such an error.  However the fix was quite simple for me, just make sure the fully directory name + abortion doctors project name + files are not longer than 248 characters.  A lot of people seem to put their projects in something like C:\Users\Celtic_Coder\Documents\Visual Studio 2010 which is already using up 50 character from that 248 character limit!

Visual FoxPro SELECT UNION and ORDER BY

Found a lovely weirdy in Visual FoxPro 7 and using UNION and ORDER BY, try the following:-

SELECT Field1, Field2 FROM Table1;

UNION ALL ;

SELECT Field1, Field2 FROM Table2;

ORDER BY Field2;

INTO CURSOR Table3

This statement creates the error:-

SQL: ORDER BY clause is invalid.

This is perfectly good SQL syntax so why is FoxPro not allowing it? 

Well not sure why by a way around it is using the ORDER BY with abortion pill ny a field value so the code best pills would now be:-

SELECT Field1, Field2 FROM Table1;

UNION ALL ;

SELECT Field1, Field2 FROM Table2;

ORDER BY 2;

INTO CURSOR Table3

SharePoint read-only mode

Had a interesting issue, our WSS 3.0 (SharePoint) internal site wasn't allowing users to upload/edit or delete files in the document library.  On closer inspection everything was correct with the library permissions.  Then I noticed the "View All Site Content" hyperlink was also missing.  So what had happened to SharePoint?  Well it seemed the morning's backup had failed and SharePoint had placed the site in a read only state (I presume to protect users adding more content when we didn't have a good previous backup file).

The Fix:-

Open SharePoint 3.0 Central Administration

Select "Application Management tab"

Under "SharePoint Site Management" section - select "Site collection quotas and locks" hyperlink

Under the how much is abortion "Site Lock Information" section is something other than "Not Locked" otc abortion pill selected (ours was set to Read-only (blocks additions, updates, and deletions).

Just tick "Not locked" and your site should now work correctly.

SharePoint JavaScript issues

A custom bit of code using JavaScript wasn't firing within WSS 3.0 (SharePoint) but only a handful of internal users.  TDD When looking at their computer I notice a script error in abortion places IE:-

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.3)

Message: Library not registered.

Line: 1946
Char: 4
Code: 0
URI: http://Portal/_layouts/1033/init.js?rev=yOq8IoAABYCtaZjMVrjxtg%3D%3D

It seems that when Outlook 2003 was uninstalled and Outlook 2010 was installed a dll gets unregistered and not re-registerd again.  The file is called name.dll.

So to Fix:-

In CMD navigate to:-
C:\Program Files (x86)\Microsoft Office\Office14

And run the following command:-
Regsvr32 name.dll

Then close all IE windows and try it again and all should be good.

Permission error with Dynamics AX 2012 and SSRS 2008 r2 report

When trying to run FreeTextInvoice.Report from Dynamics AX 2012 using SSRS 2008 r2 keep getting the following error whilst trying to print:-

Error while setting server report parameters. Error message: The permissions granted to user 'TestUser' are insufficient for performing this operation. (rsAccessDenied)

Stack trace: Call to TTSCOMMIT without first calling TTSBEGIN.

Stack trace

(S)\Classes\CustPrintOutInvoice\printOut - line 123
(C)\Forms\CustFreeInvoiceListPage\Methods\printInvoice
(C)\Forms\CustFreeInvoiceListPage\Designs\DesignList\PrintSelected\Methods\Clicked

Also looking at SQL Server 2008 how to get a abortion abortion pill online r2 SSRS Log files at:-
C:\Program Files\Microsoft SQL Server\ServerName\Reporting Services\LogFiles

ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: , Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: The permissions granted to user 'TestUser' are insufficient for performing this operation.;

Fix was quite easy but not obvious to find:-

Bascially check all folder permissions and that they are inheriting from the root.

e.g. this particular report FreeTextInvoice.Report is contained within the DynamicsAX/StaticReports/en-GB (and other languages).  But for some reason this folder didn't inherit the permissions from the root (DynamicsAX).

So all I do is navigate to the folder and then click the "Revert to Parent Security".

SQL Server Hard Drive Performance with SQLIOSIM.exe

If you are having some strange performance issues on SQL Server, I usually like to see how the Hard Drive is performing.  Microsoft released a great tool called SQLIOStress.exe.  However this has now been superseeded with SQLIOSim.exe.  You can download either the x86 or x64bit version from Microsoft.

Bascially all it does is attack the Hard Drive in similar scenarios as SQL Server would. So to run:-

Load SQLIOSim.exe and remove all drives apart from abortion centers the ones where you will have the SQL Database files save e.g. this is the default when I run on my server:-

So just select the files and click remove to get something like:-

Click OK

Then click the top right hand icon to start the test:-

There are plenty of documents on the internet to interpret the result and what they mean.  But I would also recommend downloading the SQLIOSimParser (just search in abortion facts codeplex) as this converts the results file into a simple to read csv file (just open it in Excel).

"Page cannot be found" Running Asp.Net 4 on Windows Server 2003 IIS6

Trying to run Asp.Net code from a Windows 2003 server running IIS 6.0 and I got a lovely "The page cannot be found"? 

This is bizarre as I have installed .Net 4.0 on the server, correctly ran C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe (just encase) and abortion at 6 weeks also abortion information correctly changed the properties of my Web Application to ASP.Net Version 4.0.30319

Looking at the actually Web Page error and I notice 404.2 - Lockdown policy prevents this request.  Ok nice so you can install .Net 4 for Asp.Net code but by default not actually use it?

Next check what extensions are available on the server:- open command line and enter:-
c:\Windows\System32\cscript iisext.vbs /listfile

Notice that C:\Windows\Microsoft.Net\Framework\v4.0.30319\aspnet_isapi.dll has a Zero meaning disabled.

OK to enable just run the following:-
c:\Windows\System32\cscript iisext.vbs /enfile C:\Windows\Microsoft.Net\Framework\v4.0.30319\AspNet_Isapi.dll

And bingo all code working fine now.