Thursday, May 5, 2016

Performance Tuning for ASP.NET

Found a good article at c-sharpcorner.com  with lots of suggestions for improving performance of an ASP.NET web site.      Click this link to see the article. 


Visit www.BlueCanyonSoftware.com if your business needs custom software development.

Tuesday, March 29, 2016

Case Insensitive SQL Search for Missing Values in Another Table

Problem: 

You need to compare two tables to find values in one table that are missing in the other table.   SQL server default is case insensitive so if "Dog" is in table A and "DOG" is in table B there is a match.    

Solution:  

You need to set the COLLATE value to get your desired result of a case sensitive comparison. 

We will compare two tables,  The graniteRequested table has a 'Color' column.  The colorGranite table has a 'color' column.   

This SQL query will look for colors that are in the graniteRequested table but not in the colorGranite table. 

SELECT DISTINCT gR.Color   
  FROM graniteRequested gR
  WHERE gR.Color NOT IN 
  (SELECT colorGranite.color   Collate SQL_Latin1_General_CP1_CS_AS   FROM colorGranite)


 Collate SQL_Latin1_General_CP1_CS_AS   makes this a case sensitive search. 


Visit www.BlueCanyonSoftware.com if you need custom software development for your business.


Tuesday, February 2, 2016

List SQL Server Database Tables and Columns

Query for Showing All Tables and Columns in Your Database

Do you need a list of all the tables in your database and their columns?

Use SQL Server Management Studio to connect to your database.   Execute this query, substituting your database name in the USE statement.


USE YOUR_DATABASE_NAME;
SELECT OBJECT_SCHEMA_NAME(T.[object_id],DB_ID()) AS [Schema],
        T.[name] AS [table_name], AC.[name] AS [column_name],
        TY.[name] AS system_data_type, AC.[max_length],
        AC.[precision], AC.[scale], AC.[is_nullable], AC.[is_ansi_padded]
FROM sys.[tables] AS T
  INNER JOIN sys.[all_columns] AC ON T.[object_id] = AC.[object_id]
 INNER JOIN sys.[types] TY ON AC.[system_type_id] = TY.[system_type_id] AND AC.[user_type_id] = TY.[user_type_id]
WHERE T.[is_ms_shipped] = 0
ORDER BY T.[name], AC.[column_id]


Right-click on the query results grid and select "Save Results As..."
Choose the .csv file format so you can open the file in Excel.



Visit www.BlueCanyonSoftware.com if you need custom software development for your business.

Wednesday, December 23, 2015

Copy SQL Server Database

  • Create a backup on the source SQL Server
  • Copy the .bak file to the destination computer.
  • Note the file name and location of the .bak file on the destination computer.
  • Execute this SQL Query in the destination computer
    • RESTORE DATABASE <YourDatabase> 
      FROM DISK='<the path to your backup file>\<YourDatabase>.bak'

Visit Blue Canyon Software if you need custom software for your business.

Tuesday, December 1, 2015

Best Practices for Sharing Facebook Posts to Your Website

Facebook uses meta tags in your website to manage posts that link to your website.   Visit Sharing Best Practices for Websites and Mobile Apps to learn more.

Visit Facebook Object Debugger to evaluate your website.

Visit Blue Canyon Software if you need custom software development for your business. 

Thursday, October 1, 2015

Setting Focus for Barcode Scan Input

 

Barcode scanners read barcode data and "write" the data into an area waiting to receive the data.  You could open Notepad and scan a barcode right into notepad.    On a web site, we need a textbox or other input control to receive the scanned data.

We could force our users to physically click a text box before scanning but it is normally better to have the input control selected by the software  so the user can scan without repeatedly clicking an input control.

The Solution Seems Obvious Unless Your Using IE9

A couple of solutions seem to be obvious choices.   
  1. Call the Focus() function on the input control in the OnPreRender event handle. 
  2. Call the Focus() function on the input control using JavaScript in the window onload() event.

Neither one of these solutions work on the page_load() when the input control is AJAX enabled. The window onload() event is raised before AJAX enabled controls are intialized. 

And the Answer Is ...Sys.Application.add_load()

We need to find a place to set the focus after ALL controls have been created and initialized.   We need this event to be raised after every AJAX call as well.   Add this code in a <script></script> section in your .ASPX page 

Sys.Application.add_load(applicationLoadHandler);

function  applicationLoadHandler() {
           // Call function to set focus on the scanning input control.             
           SetFocusForScan();

}


Visit www.BlueCanyonSoftware.com if you need custom software for your business.

Thursday, September 24, 2015

RadAjaxManager and ClientIdMode="Static"

You may encounter this error when using the RadAjaxManager with controls that have their ClientIdMode set to Static.  

ASP.NET applies a prefix to all control IDs.  You can remove this prefix by setting the ClientIdMode property of  a control to "Static".   This makes it a little easier to access a control in Javascript using the controls' ID. 

This works just fine unless...... you're using the control in a RadAjaxManager.   Look at this code generated by the RadAjaxManager. with the txtScan ClientIdMode="Static"
Notice  id="txtScan"; just as you would expect when the ClientIdMode is Static.  However the RadAjaxManager wraps the control in a RadAjaxPanel and the name has the prefix characters added. This causes the "Unable to get property" error shown at the start of this article. 


Here is the generated code using ClientIdMode="Auto".
The prefix is added to the id.

You'll need to use syntax like this in your JavaScript code
var theTxtScanInput = document.getElementById('<%=txtScan.ClientID%>');   You may need to wrap your <script> section within a <telerik:RadCodeBlock runat="server">.



Moral of the Story

Don't use ClientIdMode="Static" when you're using the RadAjaxManager!



Visit www.BlueCanyonSoftware.com if you need custom software for your business.