A home for developers who
love clean, working code

My name is Steve Gray, and the code on this site is the result of many years of developmental consulting. My path has been a little different from most developers I’ve met—I’ve never coded on a team. It’s always been just me, occasionally with one or two others. My work has focused on short 2, 4, or 8‑week engagements building modifications for Microsoft accounting systems. Those systems relied heavily on VBA behind the scenes, which is why I chose the VB route instead of C#.

I code in a very specific, repeatable way: data access is always SQL, using stored procedures, and I built my own data‑access scaffolding. I use the Telerik suite of controls for both WinForms and ASP.NET projects.

The jobs are never identical, but they rarely stray far from familiar patterns. Early on, I realized it would be far more efficient to maintain a library of reusable code as I moved from project to project—and this site is that library. I hope it helps.

Find code solutions by technology

Browse topics across .NET, SQL, web development, and more to quickly find practical solutions and real-world code examples that solve everyday developmental challenges.

Most Recent Articles

These are the last 10 or so places I've been. It's a fair indicator of what technology has my attention at the moment.
 

Delegates are a tool to raise an event from one class to another, from one form to another, or any combination.

Let's say that you have a form that shows customers, and a popup dialog that gives you a grid of customers to choose from. We'd like to raise an event in the frmChooseCustomer to let frmCustomerEdit know that a customer has been chosen. So, lets start in frmChooseCustomer:

There are four tasks:

This is the basic pattern for creating new WinForms forms

Large lookup lists should not load every record when the page opens. A Telerik RadComboBox can load a small initial batch, filter as the user types, and retrieve additional rows only when the user scrolls.

This example uses the Architect selector on the CRM Project card. It returns 25 Architects at a time and supports both type-ahead filtering and virtual scrolling.

How It Works

The solution has three parts:

  1. A SQL stored procedure accepts:
    • The text entered by the user.
    • The number of records already loaded.
  2. The RadComboBox requests additional results as the user types or scrolls.
  3. The ItemsRequested event passes Telerik’s e.NumberOfItems value to SQL as the offset.

The result is a lazy-loaded lookup:

  • Initial open: first 25 active Architects.
  • User types design: first 25 Architect names containing design.
  • User scrolls: next 25 matching records are loaded.
  • The dropdown stops requesting more records when SQL returns fewer than 25 rows.
The full error message is this: You're attempting to log in from a data source using a trusted connection. Update the SQL Server settings for this data source to disable trusted connections and try logging in again
 
Fix below. 
 
I'm not writing this for anybody but myself. I end up having to write a number of websites that use authentication, and I want to write down the authentication pattern that I use so that I can copy it between websites. If it's a value to anybody else, you're welcome to it. But have low expectations
Working with MDI applications in WinForms is straightforward—right up until you try to center a child form. Developers often assume that setting StartPosition = CenterParent will place the form in the middle of the MDI container, but MDI children don’t follow the same rules as modal dialogs. Instead, they ignore the setting entirely and appear in the top-left corner. In this article, we’ll walk through a simple, reusable pattern for opening MDI child forms centered inside the parent window, along with clean VB.NET examples you can drop into your project.
The new Telerik licensing depends on putting a reference to the license key into the 'base' application. The assumption is that you have control over all the code. 
 
Dynamics GP developers don't, 'Dynamics.exe' is out of our control. I've been working with Telerik support for a bit (who doesn't love unlimited free support?) and below are the exact steps to get it working. I'll also include any other reading that I have, in case my solution does not work for you.
 
Working with comma-separated values in SQL Server used to require awkward loops, XML parsing, or custom functions. STRING_SPLIT changed that. It gives you a fast, native way to turn a delimited string into a rowset you can join, filter, or aggregate. Whether you're passing a list of IDs from .NET or storing multi-value fields in a legacy table, STRING_SPLIT lets you query them cleanly and efficiently. In this article, we’ll walk through how it works, how to trim values, how to join it to your tables, and the key differences between SQL Server versions.


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences