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.

MSDN subscriber downloads is getting a new look

If you have an MSDN subscription you have seen this thing for way to long. But you might have noticed the “Try the new beta site” link and when you click that, you get this. And when you click browse, products A-Z thing you get this. But the whole point of a beta is that people try it out and tell MS what is wrong with it so they can decide if it is worth the trouble of fixing or by design.

Read More...

Multithreading pings now with Visual studio Async CTP SP1 refresh

Introduction A while back I did a post about how to do pings in a multithreaded way and show them in a grid. I will now try to use the new Async way of doing things. Multithreaded This is the code I used for the multithreaded part. Imports System.Threading Imports System.Threading.Tasks Imports System.Net.NetworkInformation Partial Public Class Form1 Private fThread As Thread Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load fgrid.Columns.Add("Ip", "Ip") fgrid.Columns.Add("Ping", "Ping") fgrid.Columns(0).Width = 100 fgrid.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill fgrid.Rows.Add() fgrid.Rows(0).Cells(0).Value = "google.com" fgrid.Rows.Add() fgrid.Rows(1).Cells(0).Value = "lessthandot.com" fgrid.Rows.Add() fgrid.Rows(2).Cells(0).Value = "bing.com" fgrid.Rows.Add() fgrid.Rows(3).Cells(0).Value = "yahoo.com" fgrid.Rows.Add() fgrid.Rows(4).Cells(0).Value = "127.0.0.1" End Sub Private Sub ThreadProc() Parallel.For(0, fgrid.RowCount, Sub(b) fgrid.Rows(b).Cells(1).Value = "Pinging " & fgrid.Rows(b).Cells(0).Value.ToString fgrid.Rows(b).Cells(1).Style.BackColor = Drawing.Color.White CheckOnline(b) End Sub) End Sub Private Sub CheckOnline(ByVal rowindex As Integer) Dim _ping As New Ping Dim _success As Boolean = False Try Dim _pingreply = _ping.Send(fgrid.Rows(rowindex).Cells(0).Value.ToString, 2000) If _pingreply.Status = IPStatus.Success Then _success = True End If Catch ex As Exception End Try SetOnline(rowindex, _success) End Sub Private Sub SetOnline(ByVal rowindex As Integer, ByVal success As Boolean) If Not success Then fgrid.Rows(rowindex).Cells(1).Value = "Offline" fgrid.Rows(rowindex).Cells(1).Style.BackColor = Drawing.Color.Red Else fgrid.Rows(rowindex).Cells(1).Value = "Online" fgrid.Rows(rowindex).Cells(1).Style.BackColor = Drawing.Color.Green End If End Sub Private Sub PingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PingToolStripMenuItem.Click fThread = New Thread(New ThreadStart(AddressOf )) fThread.IsBackground = True fThread.Start() End Sub End Class With this as the result.

Read More...

Visual Studio Async CTP videos

There a some nice visual studio Async videos on MSDN. There are videos for VB.Net and C#. VB.Net Introduction to the Async CTP 5 minutes 48 seconds Polling and Cancellation 7 minutes 24 seconds Offloading Work with TaskEx.Run 4 minutes 43 seconds Concurrent Downloading with TaskEx.WhenAll 3 minutes 6 seconds Refactoring Functionality into a Library 4 minutes 41 seconds C# Introduction to the Async CTP 5 minutes 49 seconds Concurrent Downloading with TaskEx.WhenAll 3 minutes 02 seconds Offloading Work with TaskEx.Run 4 minutes 42 seconds Polling and Cancellation 7 minutes 17 seconds Refactoring Functionality into a Library 4 minutes 54 seconds You can download the Async CTP SP1 refresh from MSDN. And you can shoot the person that named it while you are there.

Read More...

How a VB.Net programmer can annoy his C# colleague: The curious case of case insensitivity

Introduction One of the big differences between C# and VB.Net is the fact that VB.Net is case insensitive and C# isn’t. The case-insensitivity of VB.Net is sometimes weird and can lead to unwelcome side effects. Like you will see. Partial classes For example. the following is completely legal in VB.Net Module Module1 Sub Main() Dim t = New Test t.Test() t.partialtest() Dim t2 = New test t2.Test() t2.partialtest() Console.ReadLine() End Sub End Module Public Class test Public Sub Test() Console.WriteLine("test") End Sub End Class Partial Public Class Test Public Sub partialtest() Console.WriteLine("partialtest") End Sub End Class Watch the casing of the classes.

Read More...

T-SQL Tuesday

This month's T-SQL Tuesday Wednesday topic is all about failure. To be exact, Crap Code. I'm not going to post any code but instead post the problem, solution and coding initiative that were taken. Code was the "crap" part that in all was the failure in this real-life event. For the record, the story I am about to tell everyone in this post, is a real-life story that I did early on in my career. Although it is my hope to always teach in order to prevent things like this particular failure to happen to all of you, I also have the belief that we learn from failure. Sometimes, a person just needs to have the reaction and heart pumping feeling from a complete failure that affects thousands of users, in order to harden how we need to approach anything. 

Read More...

The Like keyword in VB.Net and the equivalent in C#

Introduction The Like keyword in VB.Net is not very well known, I just found out today ;-). Well I have probably seen it before but I keep forgetting it is there. But writing about it helps me to remember. VB.Net The Like keyword in V.Net works like the Like keyword in SQL. The following passing tests prove this. Imports NUnit.Framework &lt;TestFixture()&gt; Public Class LikeTests &lt;Test()&gt; Public Sub IfLikeReturnsTrueWhenUsingOneCharacterWildcard() Assert.IsTrue("st" Like "?t") End Sub &lt;Test()&gt; Public Sub IfLikeReturnsFalseWhenUsingOneCharacterWildcardFindsNothing() Assert.IsFalse("test" Like "?t") End Sub &lt;Test()&gt; Public Sub IfLikeReturnsTrueWhenUsingMultiCharacterWildcardBeginswith() Assert.IsTrue("test" Like "te*") End Sub &lt;Test()&gt; Public Sub IfLikeReturnsTrueWhenUsingMultiCharacterWildcardEndswith() Assert.IsTrue("test" Like "*st") End Sub &lt;Test()&gt; Public Sub IfLikeReturnsTrueWhenUsingMultiCharacterWildcardInBetween() Assert.IsTrue("test" Like "*st*") End Sub &lt;Test()&gt; Public Sub IfLikeReturnsFalseWhenUsingMultiCharacterWildcardAndNothingIsFound() Assert.IsFalse("test" Like "*a*") End Sub End Class``` What the above tell us is that we can use wildcards (? for one character and * for multi character). You can find [everything about Like on MSDN][1]. ## C# There is no equivalent of this in C#. 😉 <span class="MT_red">Edit</span> But you can reference the VisualBasic Assembly if you want. And then write something ugly like this. ```csharp using System; using Microsoft.VisualBasic; using Microsoft.VisualBasic.CompilerServices; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Console.WriteLine(LikeOperator.LikeString("Test", "*t", CompareMethod.Text)); Console.ReadLine(); } } }``` Perhaps there is even a better way to do this. ## Conclusion Something you should now exists because it can be very handy someday. At least you can avoid using regexp for the above cases. So this falls under the category, good to know. [1]: http://msdn.microsoft.com/en-us/library/swf8kaxw.aspx

Read More...

T-SQL Wednesday #21 – T-SQL That Should Have Been Flushed Down the Toilet

It’s T-SQL Tuesday Wednesday again! This month’s topic, hosted by Adam Machanic, is “Crap Code”. We’ve all seen it, and we’ve all written it. Even me. Here’s one of my stories. The Code Once upon a time, not so long ago, I didn’t know much about T-SQL. I knew the difference between SELECT and DELETE, but the nuances of OVER() and the capabilities of CTEs were unknown to me. At the time, I was splitting my time between help desk calls and writing reports for a small company. The systems were old, but solid.

Read More...

SQL Server Code Name "Denali" CTP3 Product Guide available for download

This is pretty cool and it is all in one place, the download is 456.0 MB I went through the guide and have listed all the white papers, demos, datasheets etc etc. _The SQL Server Code Name “Denali” CTP3 Product Guide includes useful resources and demos that will help IT Professionals better evaluate of CTP3. This includes: **14 Product Datasheets**</p> Denali Overview SQL Server High Availability Features Security and Compliance Managed Self-Service BI Reporting Services Analysis Services Predictive Analysis Data Quality Services Master Data Services Integration Services HP Microsoft Business Data Warehouse Appliance HP Microsoft Business Data Warehouse Appliance Poster Optimize SQL Server for Private Cloud poster Hyper-V Private Cloud 8 PowerPoint Presentations

Read More...

'LocalSqlServer' Error Deploying WebSecurity in WebMatrix/Web Pages

Several weeks ago I was working on a sample site in Web Matrix and ran into a brick wall when I attempted to implement WebSecurity against my website. It seemed no matter what I tried I was getting errors about my database, errors about a database I didn’t know about, errors trying to deploy the config file at all. After hours of debugging and random attempts at web.config hackery, I finally tried the basic starter sites and found out that those, too, suffered from problems when you attempt to deploy them.

Read More...

Desktop Computing is Dead

As I was cleaning this past weekend, I did inventory of hardware that was floating about the house and it turns out that I have four laptops and one desktop. The desktop that I still have is one that I built around four years ago. It is up in the guest room primarily used by my two sons for school and games. This started me thinking about where we are today with computing, and desktop computing specifically. Five or so years ago, a laptop was far under powered in all areas of resources to handle running the number of instances of SQL Server and or Virtual Machines that come with the typical SQL Server Professionals daily routine of learning and testing. You could go out and spend $4000 to get a laptop that was 5 inches thick and would burn the hair off your legs, but we're being realistic for the normal geek here. Today, we have it a bit different. At a reasonable price of $1000, you can go out and purchase a solid laptop with enough disk, CPU power and memory to successfully install, configure and run SQL Server Developer. Add a few hundred to that and you are running SSD drives for your data and log files and you are screaming fast in a lot of areas of SQL Server loaded on a laptop.

Read More...