LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

Conditional formating in a DataGridView with databinding

When you databind your DataGridView to a List. Like this. First I create a class Person so I can bind to that. Watch the default constructor, it needs to make new elements, if that is what you want. Public Class Person Private _name As String Public Sub New() _name = "person1" End Sub Public Sub New(ByVal Name As String) _name = Name End Sub Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property End Class Then the DataGridView.

Read More...

How to script all stored procedures in a database

In the forums I frequent, the question of scripting all stored procedures in a database arises very often, the most recent encounter is in this MSDN thread script out many stored procedures at once? A few years ago, I asked this question myself in www.UniversalThread.com forum and Borislav Borissov helped me to come up with the following solution: set nocount on DECLARE @Test TABLE (Id INT IDENTITY(1,1), Code varchar(max)) INSERT INTO @Test (Code) SELECT 'IF object_ID(N''[' + schema_name(schema_id) + '].[' + Name + ']'') IS NOT NULL DROP PROCEDURE ['+ schema_name(schema_id) +' ].[' + Name + ']' + char(13) + char(10) + 'GO' + char(13) +char(10) + OBJECT_DEFINITION(OBJECT_ID) + char(13) +char(10) + 'GO' + char(13) + char(10) from sys.procedures where is_ms_shipped = 0 DECLARE @lnCurrent int, @lnMax int DECLARE @LongName varchar(max) SELECT @lnMax = MAX(Id) FROM @Test SET @lnCurrent = 1 WHILE @lnCurrent <= @lnMax BEGIN SELECT @LongName = Code FROM @Test WHERE Id = @lnCurrent WHILE @LongName <> '' BEGIN print LEFT(@LongName,8000) SET @LongName = SUBSTRING(@LongName, 8001, LEN(@LongName)) END SET @lnCurrent = @lnCurrent + 1 END The output of this code produces a script of all stored procedures in a database.

Read More...

Finalbuilder, Nunit and the AppDomainUnloadedException

I was running into this error when running my Nunit-tests. Executing : C:Program FilesNUnit 2.5.2binnet-2.0nunit-console.exe With Command Line : TDB2009.View.Test.C.dll NUnit version 2.5.2.9222 Copyright (C) 2002-2009 Charlie Poole. Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. Copyright (C) 2000-2002 Philip Craig. All Rights Reserved. Runtime Environment – OS Version: Microsoft Windows NT 5.1.2600 Service Pack 2 CLR Version: 2.0.50727.3068 ( Net 2.0.50727.3068 ) ProcessModel: Default DomainUsage: Single Execution Runtime: net-2.0.50727.3068

Read More...

Finding SQL Server Support – Become an expert yourself

Can I help you? There are several levels of support for SQL Server. Putting these levels on paper and knowing which to choose for your own particular problem can be a task in itself at times. I hope the following definitions of four levels of support will help you in deciding where to turn to obtain the quickest solutions. Defining levels Books and BOL User groups /Posting questions Technical forums Twitter – Yes, twitter is a rapidly growing place for expert support Books and BOL can provide solutions to problems where you have the time to both research and take great care in formulating the exact details of the problem. Books and BOL resources are also preventative solutions to problems that are more common to SQL Server. BOL comprises a vast amount of knowledge so you can get exact details on troubleshooting SQL Server. If you review BOL’s documentation on Troubleshooting Performance Problems in SQL Server 2005, you will get a perfect example. This resource has been posted for each version of SQL Server and is an excellent foundation for knowledge of key areas to check if you have performance issues. There is also a fundamental knowledge base on how SQL Server works internally and externally. If you look hard enough, you will find information on how SQL Server works from the surface to internals of the database server’s inner thought process. This level of support should be ongoing and utilized when time is available to build upon your skills as a DBA or Database Developer. Placing trust in this support level will assist you in future developments and in current and long term tuning and planning.

Read More...

SQL Saturday 33 – Charlotte, NC

This weekend was SQL Saturday #33 in Charlotte NC and also the first one I attended. It’s been a long weekend, but I wanted to get my thoughts down while they’re still fresh. Be warned, it’s been a long weekend, so my grammar and attempts to reign in my propensity for verbosity have both gone out the window. Background Sorry SQL Saturday? Tarwn and SQL? We have questions and we know how painful it is for you to write short blog posts…

Read More...

C# Dynamic Data Layer

Update: I added some code to handle DBNulls. With the upcoming release of .NET 4.0 we will be seeing the new dynamic type introduced. The dynamic type bypasses static type checking and is instead checked at run-time. It was introduced to improve interoperability with dynamic languages like IronPython as well as simplifying the usage COM APIs that return objects such as the Microsoft Office API. How can we take advantage of this in other areas? ADO.NET is a perfect candidate for taking advantage of the dynamic type. The following code lays out the ground work for a nice simple class that returns dynamic objects from the database.

Read More...

Turning Napkins to HTML With Napkee

A few months ago, I was lucky enough to try out Balsamiq mockups and review it in a blog post (Turn Any Computer into a Napkin). In January I saw a bit of chatter about a new tool called Napkee that was built to enable easy generation of a working user interface from a Balsamiq mockups layout. The tool works with both HTML and AIR/Flex outputs, I am really only interested in the HTML part, so if you are looking for info on how it works with AIR/Flex turn back now. I’ve been using Balsamiq rather heavily in a side project of mine, and I got very excited about the prospect of being able to create HTML directly from it. Much like Balsamiq, Napkee has a variety of criteria for free licenses and they were gracious enough to grant me one.

Read More...

Calculating Nth weekday in a month

How to calculate the Nth week day of a month? This will be useful in most of the Scheduling problems like Scheduling Jobs, Appointments etc. Let me demonstrate how we can achieve this: Let us take an example of say, 3rd Sunday in February, 2010 will come on 21st February, 2010. The solution to the above problem needs to satisfy 3 conditions. The date should be in the specified month and year.

Read More...

Do You Get A Benefit From Compressing Backups If You Already Have Compressed Data?

Do you benefit from compressed backups if your data is compressed already? This was a question that was asked recently; I thought that the question was interesting and decided to do some testing. Here is what we will do; we will create two databases with only one table. In one database we will use page level compression and in the other database we won’t use compression. After that we will backup each database twice, once with backup compression and once without backup compression. After that, we will do restore from these backups. After doing all these, we will find out if data compression makes backup compression faster. We will also find out if using backup compression on a database that uses data compression will result in a smaller backup file. At the bottom of this post you will see a table that has all these numbers in one spot.

Read More...

Choosing operating modes for mirroring over a WAN

To sync or async… Over the weekend on twitter, the topic of high availability over a Wide Area Network (WAN) came up. The limit of 140 characters doesn’t do this topic justice, so a follow up is a good idea. We’re going to focus on selecting an operating mode of mirroring that the business can handle then the mirror is spread over a WAN. This also came out of the conversations when synchronous mirroring (High Availability) was mentioned in a way of being over Asynchronous (High performance). To answer the question directly, High performance cannot provide you with out of the box automated failover and there is the chance for data loss. So for an absolute option of High Availability, High performance cannot fully replace it. There are options available when the performance load of synchronous mirroring with a witness is far too much for the business to carry.

Read More...