Jump to content


Check out our Community Blogs

Barnsite's Blog



Don’t Fall Victim To The Windows / Microsoft Phone Scam!

  Posted by Barnsite, 14 June 2017 - - - - - - · 2481 views

There are many phone scams where someone will ring you claiming to be from Microsoft, Dell, Apple, or some other known IT company.They will tell you that they have detected issues with your computer, normally “security” issues.They will often ask you to open the “Event Viewer” on your computer to show you the errors.They will then ask you to go...


Remove Characters in String T-SQL with No Loop Part 2

  Posted by Barnsite, 09 May 2016 - - - - - - · 10918 views

Okay, expanding on what I did yesterday.I Built a table, called ExclusionList with one field, ExcludedTextE.g.Then created a function:CREATE FUNCTION [dbo].[udf_clean_string] ( @string VARCHAR(100) ) RETURNS VARCHAR(100)ASBEGIN SELECT @string = REPLACE(@string,ExcludedText,'')FROM ExclusionListRETURN @stringYou can then use like this:SELECT d...


Remove Characters in String T-SQL with No Loop

  Posted by Barnsite, 09 May 2016 - - - - - - · 9743 views

Ok, I’ve seen many ways to do this using loops, but nothing in plain T-SQLLet’s say we have a string that may contain illegal characters, in my case it was project identifiers that needed to be used as file names for exporting. However, many had / or * in the names.One thing I hate in T-SQL is loops, so having only found looping ways...


Add child items to ToolStripMenuItem using C# – C Sharp

  Posted by Barnsite, 22 January 2013 - - - - - - · 5578 views

I wanted to be able to populate menu items from a database, i.e. I had a Print Document top level menu item and I wanted to be able to populate the children from the database dynamically with each available document.
The theory was this:
1. Use the MouseHover event for the main menu item
2. When the user hovers over the item, get the list of...


Shuffle an Array in C#

  Posted by Barnsite, 15 January 2013 - - - - - - · 2788 views

As part of a basic guessing game I wanted to be able to shuffle an array of n chars into a random order.
The method I decided to use was the following.
Create a loop to iterate n times (where n is the number of elements in the array).  Randomly select one array element and add this to a new array.  Replace the removed item with the last item in...


Loading Data into a DataReader and Looping Through Records OLEDB / C#

  Posted by Barnsite, 24 December 2012 - - - - - - · 2089 views
programming
Just a quick example of loading data into a data reader using C#.  My data source is MS SQL Server in this case, although you would just need the correct OLEDB connection string to use any other data source.

//database connection string & SQL Statement to return SERVICE_LEVEL_ID and DEFINITION from a table called property.SERVICE_LEVEL
string...


Changing Default Parameter Value SSRS (SQL Server Reporting Services) 2008

  Posted by Barnsite, 17 December 2012 - - - - - - · 1917 views
programming
If you’re here you have probably found that if you’ve deployed a report to your server updating the default parameter values and redeploying has no effect on the server report.
E.g. I had a report with an integer parameter with a default of 25 that had been deployed to the server.  On my development machine I updated the default value and...


Image Slideshow on Windows Form C# with Timer Control

  Posted by Barnsite, 07 December 2012 - - - - - - · 3123 views
programming
Quick example of how to display an image control that loops through a folder of images.
Firstly drop a timer control onto your form (name: tmrNextImage), set the Interval to 1000 milliseconds (1 second) and set enabled to true.
Next drop a PictureBox control onto your form (name: imgPicture) and set SizeMode to Zoom (this will force your image to fit the...


Find all Subdirectories from a given path using C# – With Error Handler

  Posted by Barnsite, 07 December 2012 - - - - - - · 932 views
programming
In my earlier post () I showed how you can iterate through folders and add the folder names to a list (lstDirs).  The problem with this code was that if you encountered a folder you didn’t have access to it all fell over.  Below I’ve added a function to test the folder access (canReadDir()), if the folder is inaccessible the path is added to...


Search for Value in Multiple Columns SQL Server T-SQL

  Posted by Barnsite, 04 December 2012 - - - - - - · 947 views
programming
Having to write some SQL SELECT’s on some un-normalized tables left me thinking there has to be a tidier way. I started with:

SELECT
*
FROM bags.SAC_LOG
WHERE [SCANNERID_1] = @SCAN_ID
OR [SCANNERID_2] = @SCAN_ID
OR [SCANNERID_3] = @SCAN_ID
OR [SCANNERID_4] = @SCAN_ID
OR [SCANNERID_5] = @SCAN_ID
OR [SCANNERID_6] = @SCAN_ID
OR [SCANNERID_7] =...