Let’s say you’re writing T-SQL code and need to make sure that your query returns one and only row. If no records returned – an error message needs to be shown. If more than one record is returned – another error message needs to be show. The code goes something like this:
-- ... query runs here and returns row
IF @@ROWCOUNT = 0 RAISERROR('No records found', 18, 1)
ELSE IF @@ROWCOUNT > 0 RAISERROR('More than one record found', 18, 1)
-- ... continue when exactly one row is returned
Now if your query returns 3 records you’d expect it to trip the second IF statement and raise error with correct message. Unfortunately this doesn’t happen. The reason being – the first IF statement resets @@ROWCOUNT to 0. So, to avoid this we need to preserve the @@ROWCOUNT value in a local variable:
DECLARE @iRowCount int
-- ... query runs here and returns row
SET @iRowCount = @@ROWCOUNT
IF @iRowCount = 0 RAISERROR('No records found', 18, 1)
ELSE IF @iRowCount > 0 RAISERROR('More than one record found', 18, 1)
-- ... continue when exactly one row is returned
This way count of rows returned by the query is saved and is not affected by any following statements.
If you’re using Infragistics UltraWebGrid with ExcelExporter and your grid has columns marked as “ServerOnly” – they’re visible in exported Excel worksheet even though the grid doesn’t show them onscreen. To hide these column in exported file, mark them as “Hidden” as well. This will have no additional effect on the way grid looks on screen, but the columns will be gone from the worksheet.
Consider following scenario: While developing for SQL Server Reporting Services you created a report in Business Intelligent Studio (or generated RDL file elsewhere and then added it to Studio’s project). Everything works fine, you’re able to preview report. And then you need to change Data Source (one example: you created a shared Data Source and now want your report to use it). After you do that any attempt to run the report results in error: Query execution failed … Expected parameter ….
The reason in this case – when you change the data source thru GUI – it resets query used by the report. It can change query type from StoredProcedure to Text and also remove all default query parameters (hence error above).
There’re 2 possible solutions here: First – instead of using GUI, manually change Data Source in the XML source of the report file (in Solution Explorer right mouse click on the report file and select “View Code”). You will have to change it in several places, so be careful. Second – re-create query with its default parameters after changing Data Source in GUI.
If you’re trying to use a standard ASP.NET button control as a trigger for your AJAX UpdatePanel’s async postback – and it doesn’t fire, try setting button’s UseSubmitBehavior property to False. This will render button as a standard button with __doPostback() call instead of Submit button in HTML markup and will solve your problem.
If you’re using Crystal Reports 2008 in your ASP.NET application, and after deploying to a 64bit server getting following error:
An error has occurred while attempting to load the Crystal Reports runtime. Either the Crystal Reports registry key permissions are insufficient, or the Crystal Reports runtime is not installed correctly. Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required. Please go to http://www.businessobjects.com/support for more information.
then switch your application to 32bit mode. In case of Windows 2003/IIS6 entire server will have to be switched, in case of Windows 2008/IIS7 a dedicated 32bit application pool can be established for your application.
Recently I upgraded an ASP.NET project from ancient 6.3 version of Infragistics to current (at the moment) 9.2. Suddenly UltraWebGrid control began to display an unpleasant effect – columns that used to have no caption now showed what appeared to be default captions:

Looking at grid’s HTML markup I noticed that it set the caption to an empty string (showing code for one column):
<igtbl:UltraGridColumn HeaderText="">
<Header Caption="">
</Header>
</igtbl:UltraGridColumn>
Apparently it’s a new behavior in Infragistics 9.x to substitute empty captions with default column names. The solution is to set caption to a single space which, while invisible, is considered a real text caption and is not substituted by anything:
<igtbl:UltraGridColumn>
<Header Caption=" ">
</Header>
</igtbl:UltraGridColumn>
The result:

If you still use Visual Studio .NET 2003 (I still do for some older .NET 1.1 projects) you may experience following situation:
- You have an ASP.NET Web project that is controlled by Visual SourceSafe
- While opening the project Visual Studio 2003 hangs, stops responding to mouse clicks and keystrokes.
Fortunately there is a quick fix to that.
Continue reading 'Visual Studio 2003 hangs trying open ASP.NET project from Visual SourceSafe'»
Let’s say in your ASP.NET application you set a TextBox control’s property ReadOnly to True (or Enabled to False) to prevent user from entering data directly. But you still want to update that text box’s value via client-side JavaScript. Which is happening, the value can be updated. But during postback to the server – surprise, surprise! – the new value doesn’t persist. This is due to security precaution – if the value wasn’t meant to be changed – the change is not allowed. But there is a way around this.
Continue reading 'Postback disabled/readonly Textbox that was modified in JavaScript'»
I was running a basic LINQ 2 SQL statement:
From role In db.user_role _
Where role.USER_ID = Session("user_id") Select role
when I encountered following error message:
Method ‘System.Object CompareObjectEqual(System.Object, System.Object, Boolean)’ has no supported translation to SQL.
After a little research I found the solution.
Continue reading 'Method ‘System.Object CompareObjectEqual(System.Object, System.Object, Boolean)’ has no supported translation to SQL. Solution to error'»
Infragistics WebDataMenu is a light-weight highly responsive menu control with rich server and clinet side model. I was using it to display context menu on right mouse click. The code is pretty simple:
function onMouseClick(oEvent) {
if (oEvent.button == 2) { //right mouse button clicked
var menu = $find("xwdmMyMenu");
menu.showAt(null,null, oEvent);
}
}
It checks whether the right mouse button was clicked (line 2) then locates the menu object and shows it using showAt method (which accepts 3 parameters, either X and Y client coordinates, or event object from which it derives coordinates of the mouse click).
It’s all well and good, but the problem is – menu always shows down from the location of the mouse click. And if the click is at the bottom of the screen – menu gets cut off:

I needed to make menu expand UP and couldn’t find a build-in property or method that would change this behaviour (GroupSettings.ExpandDirection property had no effect). Time for a little hack. Continue reading 'Infragistics WebDataMenu: Expanding context menu UP'»