Saturday, September 26, 2020
Beetle Blog
1 2 3
By: douglas - Sql Server - 2/28/2014 12:26:25 PM

 Exception Message:

INSERT failed because the following SET options have incorrect settings: 'ANSI_NULLS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
In this case it is possible one of your stored procedures has SET ANSI_NULLS OFF.  Change it to "ON".

By: douglas - - 4/14/2013 12:58:34 AM

Following this tutorial:
WebMatrix 2 or 3 (This will also work with 2010, 2012 using the WebPages framework)
Open WebMatrix
Create a new WebPages site.
Using NuGet install the Microsoft ASP.NET SignalR package: Microsoft.AspNet.SignalR
If you are installing from scratch make sure to install the entire package which is exactly Microsoft.AspNet.SignalR, not just the Core or other libraries.
It will install a bunch of JavaScript files and place the SignalR libraries (dlls) in your Bin folder.
Create an App_Code folder.
Create a C# class called ChatHub.cs in the folder.
Replace the contents with the following code:
using System;
using System.Web;
using Microsoft.AspNet.SignalR;
namespace SignalRChat
    public class ChatHub : Hub
        public void Send(string name, string message)
            // Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);
Create an _AppStart.cshtml at the root of your site.
Add the following code to _AppStart.cshtml:
@using System.Web.Routing;
@using Microsoft.AspNet.SignalR;
    // Register the default hubs route: ~/signalr/hubs
Add a new HTML page to your site.  For example: chat.html
Replace the contents with the html from the tutorial.
Take a look at the references to your .js libraries and make sure that they match what you have in the /Scripts directory. If not update the references.
If the jQuery you have is older than the one referenced then update your jQuery libraries to at least the one referenced.
Now run the site and go to your chat.html page.  You should get prompted to enter your name and then be able to submit messages to the app.
Open additional tabs or browser windows, browse to the same page and you should be able to see messages typed in other windows get sent to all other open windows.

By: douglas - Misc - 4/13/2013 4:22:47 PM

At the command prompt:

powercfg /batteryreport

It should save an html report and tell you where to find it.

By: douglas - Sql Server - 11/26/2012 8:38:33 PM

DBCC shrinkdatabase( database_name ) can take a long time and it doesn't show progress if you run it via SSMS.  To view the percent complete use this query:

SELECT percent_complete, start_time, status, command, estimated_completion_time, cpu_time, total_elapsed_time FROM sys.dm_exec_requests where command = 'DbccFilesCompact'


By: douglas - - 8/24/2010 1:10:44 AM


Your application uses the membership and roles provider and users have checked the "remember me" option when logging in that uses a persistent cookie to keep a user logged in.  If the app pool for an application is recycled the user may become logged out even though the cookie has not expired and still exists.

This issue most often appears in a web farm but can appear in a single server environment.


The cookie becomes invalid because the machine key for the application has changed after the app pool recycles.  The machine key is used to read the persistent cookie.  Since it has changed your application can no longer read the cookie and users appear to be logged out.


Add a static segment to the web.config.  This will make your application use the same machine key even after an app pool recycle.

Additional Information:

About Machine Key:

Tool for generating a Machine Key for the web.config:


By: douglas - Sql Server - 5/1/2010 7:33:52 PM

 If you try to run a very large script in SQL Management Studio (2005, 2008) it may not run.  Instead it may give a "System.OutOfMemoryException" error.

In order to run the script you can use the sqlcmd in the command line instead.

sqlcmd -S YOURSQLSERVER\INSTANCENAME -i "C:\Your Script.sql”

Example connecting to a remove database using sql server authentication:

sqlcmd -S -i -U -P -d

Note that username and password are sent using clear text.

By: douglas - Classic ASP - 2/13/2010 1:43:41 PM

By default Classic ASP is turned off on IIS7.

To enable:

  • Use the Control Panel to turn on Windows Features.  Under Internet Information Services > World Wide Web Services > Application Development Features check ASP
  • Then, for better debugging features under ASP in your IIS web site set "Send Errors To Browser" to True under "Debugging Properties" and Apply the settings.


By: douglas - - 4/10/2009 9:41:59 PM

After installing MVC v1 it is supposed to install the MVC project template into VWD2008.

If it does not, make sure you have VWD2008 sp1 and then go to "Tools" > "Import and Export Settings..." and reset the VWD settings.

Now you should be able to create MVC projects in VWD2008.

By: douglas - - 8/7/2008 1:15:13 AM

When you use a LinqDataSource as the datasource for a GridView you may run into an issue if you try to display data from a child object/table in the LinqDataSource.

For example if you have an object Order and child object Customer trying to call Customer.FirstName will be blank.  This is a bug in .net 3.5.

If you set EnableDelete, EnableInsert or EnableUpdate on the LinqDataSource the Eval statement will work.

Other workarounds and details can be found here:

By: douglas - - 5/28/2008 3:16:14 PM

This seems to be an error in the runtime.

It can happen with MasterPages or UserControls.  Often it will happen after you update a file and place it on the server. is not able to always compile properly.

There is a hotfix from Microsoft for this.

There is a workaround for this issue:


<compilation debug="false" batch="false"></compilation>


By: douglas - C# - 5/22/2008 3:56:27 AM

This code uploads an image to the server file system.  If the image is wider than a certain width it resizes the image.  The image is saved as a jpg.


        // Upload image
        // Make sure to create directory if needed.
        string savePath = Server.MapPath("~/UploadFolder/");

        // Create Directory if it doesn't exist
        if (!System.IO.Directory.Exists(savePath))

        // Declare some image variables
        System.Drawing.Image imgOriginal;  // Will hold the original image
        System.Drawing.Image imgNew;  // Will hold the new image
        double targetWidth = 100; // Default target width for new image
        double targetHeight = 100; // Default target height for new image

        // Get new width from config
            targetWidth = Convert.ToDouble(ConfigurationManager.AppSettings["MaxImageWidth"]);
            targetWidth = 100;

        //Create a new Image using the uploaded picture as a Stream
        imgOriginal = Bitmap.FromStream(ImageUpload.PostedFile.InputStream);

        // Work out a proportionate height from width
        if ((double)imgOriginal.Width < targetWidth)
            targetWidth = (double)imgOriginal.Width;
            targetHeight = (double)imgOriginal.Height;
            targetHeight = (double)imgOriginal.Height / ((double)imgOriginal.Width / targetWidth);

        // Now create the new image
        imgNew = new Bitmap(imgOriginal, (int)targetWidth, (int)targetHeight);

        // Save it to the file system as a jpg.
        imgNew.Save(savePath + "\\" + pAdID.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

By: douglas - C# - 4/28/2008 6:13:14 AM

The following will validate stringVariable to see if it matches an email pattern.

System.Text.RegularExpressions.Regex.IsMatch(stringVariable, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

There are double \ due to the language being C#.


If you are using the command prompt on Windows many directories and file names have spaces in their names.  This does not work well with the command prompt.  One solution is to put double quotes around paths with spaces:

"C:\Program Files\My File.exe"


When you have an SqlDataSource that has a SelectCommand and Select parameters.  If the select parameters are optional or null the datasource will not return any records.

This may occur when using a stored procedure.  Testing the datasource in visual studio returns records and testing the stored procedure will also return records.  However the datasource and datagrid it binds to does not return any records.

The issue may be caused by a property in the SqlDataSource: CancelSelectOnNullParameter.  This property is defaulted to true and will prevent the select command from running if select parameters are null.

Set CancelSelectOnNullParameter="false"

By: douglas - - 12/29/2007 12:23:55 AM

Here is how to start the standalone server that comes with 2005 and higher from the command line:

Start /B C:\WINDOWS\Microsoft.NET

\Framework\v2.0.50727\WebDev.WebServer.exe /port:1234 /path:"C:\YourWebSitePath"
If you place this line in a bat file you can start your web server by running the bat file.
WebDev.WebServer.exe is the web server.

By: douglas - Misc - 12/14/2007 6:37:16 PM

In 2005:

  1. Create a dataset file
  2. Drop a database table in the dataset
  3. Generate stored procedures
  4. Generate database insert, update, delete methods
  5. Close dataset file
  6. Open dataset file
  7. Configure dataset
  8. Go through wizard
  9. Now the generator does not generate the insert, update and delete methods
  10. This also happens if you create a new data set based on existing stored procedures

Possible workaround:

Creating a new TableAdapter in the DataSet Designer by right-clicking on the designer surface and choosing Add->TableAdapter. Then go through the wizard choosing Use Existing Stored Procedures. The checkbox will still be disabled but it will be checked and the DBDirect methods will be created. You will also be able to turn on/off the GenerateDBDirectMethods property in the properties window by following this workaround.

By: douglas - Misc - 11/12/2007 1:55:10 AM

Recently I've been working on is a web site all about animals and I plan to make it a cross between a blog and wiki type site.  Hopefully it can be developed enough so that people will be able to use it as a resource for animal information and pictures.

Check it out at

By: douglas - - 4/8/2007 3:29:13 PM
When using the PopupControl extender, if you run into an issue where the popup control does not pop up in the correct position when the page is scrolled you should make sure you have these HTML elements on your page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >

By: douglas - Misc - 10/18/2006 1:45:37 AM
Recently I tried out Ubuntu (   I found it to be very easy to install and use.

By: douglas - - 10/18/2006 1:23:27 AM
By default the upload control is limited to around a 2 MB upload.  Trying to upload larger files result in an error.

To set the upload capacity of the upload control place these tags in the web.config:

<httpRuntime maxRequestLength="655350" useFullyQualifiedRedirectUrl="true" executionTimeout="600" />










1 2 3

Beetle Blog v0.2.2

Copyright © 1997 - 2020 All rights reserved.