In the coming months I will be going to a few conferences. Not because I have to, but because I want to. Neither of the conferences is free. The SQL Server days 2011 one is very cheap. I only payed 79€ (early bird) for that. Which isn’t to much considering I pay for it myself. And I will get to meet mrdenny after all these years. And it will have Kevin Kline and Jen Stirrup among the many speakers. So there is no reason for all you DBA’s (Belgian or otherwise) not to come. I might be handing out some Lessthandot stickers if they let me ;-). It’s 1 and a half days on the 14 and 15th of November.
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.
Yesterday there was [this announcement from the VB-team][1]. In [a previous post][2] I wrote about the difference in namespaces between VB.Net and C#. On a project level C# uses a default namespace setting which means you can just overwrite it at the class level. So if you create a new class you will get something like this. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace C_Class_Library_1.NewFolder1 { class Class1 { } }``` But if you so desire you can change that. To this. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NewFolder1 { class Class1 { } }``` Which means that your class is in a different namespace than all the other classes in your project. In VB.Net this was never possible, because they use a root namespace at the project level. Which means that all classes in your project will be under that namespace. <div class="image_block"> <img src="https://lessthandot.z19.web.core.windows.net/wp-content/uploads/blogs/DesktopDev/namespace2.jpg" alt="" title="" width="716" height="149" /> </div> You can of course cheat and not set a root namespace and then set a namespace on each and every file/class. But [in VB11 you will no longer have to do this][1]. You can now override the root namespace setting by using the Global keyword. So if I do this. ```vbnet Namespace Global.NewNamespace Public Class Class1 End Class End Namespace Public Class Class1 End Class``` So I can now call the above classes like so. ```vbnet Dim _class1 As New NewNamespace.Class1 Dim _class1_1 As New VB_Console.Class1``` Perhaps not the coolest feature ever but it is new. But to be honest we would have prefered having project Roslyn in this version. [1]: http://blogs.msdn.com/b/vbteam/archive/2011/09/27/announcement-namespace-global.aspx [2]: /index.php/DesktopDev/MSTech/vb-net-and-c-the-difference-in-oo-syntax-4
Recently I decided to start doing JavaScript code katas. I’ve been using JavaScript for around ten years, but there there are still a lot of aspects I don’t know well or that I could use more practice in. Case in point, I had never used a unit testing framework with javascript. Having never unit tested JavaScript before, I used a scientific tool to carefully select from amongst the numerous unit testing packages available.
In this blog post I would like to touch a very common problem which often trips up newbies and even serious SQL Professionals. I wanted to write this blog post for quite some time, but always put it aside. However, just a few days ago I have been dealing with this problem at my work place, so I believe it’s time to discuss the problem. For the discussion let’s consider AdventureWorks database SalesOrderHeader and SalesOrderDetail tables. To illustrate the problem, let’s assume that returns are handled in a different table with a structure very similar to SalesOrderDetail. And let’s assume there are about 20 percent of returns (the business must not be doing too well!).
Introduction Getting into Android development is easy. Just download Eclipse and the Android SDK and you are on your way to brilliant things. And making your first app is easy. One of the first apps we wrote was a close button. In other words. Put a button on the screen and when the user clicks it then close it. The code First thing to do was to make it work. This was quit easy. First use the designer to put a button on the screen and then use this code.
Just use the colon everywhere you can. I twill make this class. Public Class Person1 Public Sub New(ByVal country As String, ByVal postcode As String, ByVal town As String, ByVal housenumber As String, ByVal street As String, ByVal firstname As String, ByVal name As String) _country = country _postcode = postcode _town = town _housenumber = housenumber _street = street _firstname = firstname _name = name End Sub Private _country As String Private _postcode As String Private _town As String Private _housenumber As String Private _street As String Private _firstname As String Private _name As String Public Property Country() As String Get Return _country End Get Set (ByVal value As String) _country = value End Set End Property Public Property Postcode() As String Get Return _postcode End Get Set (ByVal value As String) _postcode = value End Set End Property Public Property Town() As String Get Return _town End Get Set (ByVal value As String) _town = value End Set End Property Public Property Housenumber() As String Get Return _housenumber End Get Set (ByVal value As String) _housenumber = value End Set End Property Public Property Street() As String Get Return _street End Get Set (ByVal value As String) _street = value End Set End Property Public Property Firstname() As String Get Return _firstname End Get Set (ByVal value As String) _firstname = value End Set End Property Public Property Name() As String Get Return _name End Get Set (ByVal value As String) _name = value End Set End Property Public Overloads Function Equals(ByVal other As Person1) As Boolean If ReferenceEquals(Nothing, other) Then Return False If ReferenceEquals(Me, other) Then Return True Return Equals(other._Country, _Country) AndAlso Equals(other._Postcode, _Postcode) AndAlso Equals(other._Town, _Town) AndAlso Equals(other._HouseNumber, _HouseNumber) AndAlso Equals(other._Street, _Street) AndAlso Equals(other._Firstname, _Firstname) AndAlso Equals(other._Name, _Name) End Function Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean If ReferenceEquals(Nothing, obj) Then Return False If ReferenceEquals(Me, obj) Then Return True If Not Equals(obj.GetType(), GetType(Person)) Then Return False Return Equals(DirectCast(obj, Person)) End Function Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 0 If _Country IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Country.GetHashCode()) Mod Integer.MaxValue) If _Postcode IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Postcode.GetHashCode()) Mod Integer.MaxValue) If _Town IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Town.GetHashCode()) Mod Integer.MaxValue) If _HouseNumber IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _HouseNumber.GetHashCode()) Mod Integer.MaxValue) If _Street IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Street.GetHashCode()) Mod Integer.MaxValue) If _Firstname IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Firstname.GetHashCode()) Mod Integer.MaxValue) If _Name IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Name.GetHashCode()) Mod Integer.MaxValue) Return CInt(hashCode Mod Integer.MaxValue) End Function Public Overrides Function ToString() As String Return String.Format("Country {0}, Postcode {1}, Town {2}, Housenumber {3}, Street {4}, Firstname {5}, Name {6}", _Country, _Postcode, _Town, _HouseNumber, _Street, _Firstname, _Name) End Function End Class``` into this. ```vbnet Public Class Person Public Sub New(ByVal country As String, ByVal postcode As String, ByVal town As String, ByVal housenumber As String, ByVal street As String, ByVal firstname As String, ByVal name As String) _Country = country : _Postcode = postcode : _Town = town : _HouseNumber = housenumber : _Street = street : _Firstname = firstname : _Name = name End Sub private _country As String:private _postcode As String:private _town As String:private _housenumber As String:private _street As string:Private _firstname As String:Private _name As String:Public Property Name() As String:Get:Return _name:End Get:Set(ByVal value As String):_name = value:End Set:End Property:Public Property Firstname() As String:Get:Return _firstName:End Get:Set(ByVal value As String):_firstname = value:End Set:End Property:Public Property Street() As String:Get:Return _street:End Get:Set(ByVal value As String):_street = value:End Set:End Property:Public Property HouseNumber() As String:Get:Return _housenumber:End Get:Set(ByVal value As String):_housenumber = value:End Set:End Property:Public Property Town() As String:Get:Return _town:End Get:Set(ByVal value As String):_town = value:End Set:End Property:Public Property Postcode() As String:Get:Return _postcode:End Get:Set(ByVal value As String):_postcode = value:End Set:End Property:Public Property Country() As String:Get:Return _country:End Get:Set(ByVal value As String):_country = value:End Set:End Property Public Overloads Function Equals(ByVal other As Person) As Boolean : If ReferenceEquals(Nothing, other) Then Return False : If ReferenceEquals(Me, other) Then Return True : Return Equals(other._Country, _Country) AndAlso Equals(other._Postcode, _Postcode) AndAlso Equals(other._Town, _Town) AndAlso Equals(other._HouseNumber, _HouseNumber) AndAlso Equals(other._Street, _Street) AndAlso Equals(other._Firstname, _Firstname) AndAlso Equals(other._Name, _Name) End Function Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean : If ReferenceEquals(Nothing, obj) Then Return False : If ReferenceEquals(Me, obj) Then Return True : If Not Equals(obj.GetType(), GetType(Person)) Then Return False : Return Equals(DirectCast(obj, Person)) End Function Public Overrides Function GetHashCode() As Integer : Dim hashCode As Long = 0 : If _Country IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Country.GetHashCode()) Mod Integer.MaxValue) : If _Postcode IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Postcode.GetHashCode()) Mod Integer.MaxValue) : If _Town IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Town.GetHashCode()) Mod Integer.MaxValue) : If _HouseNumber IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _HouseNumber.GetHashCode()) Mod Integer.MaxValue) : If _Street IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Street.GetHashCode()) Mod Integer.MaxValue) : If _Firstname IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Firstname.GetHashCode()) Mod Integer.MaxValue) : If _Name IsNot Nothing Then hashCode = CInt(((hashCode * 397) Xor _Name.GetHashCode()) Mod Integer.MaxValue) : Return CInt(hashCode Mod Integer.MaxValue) End Function Public Overrides Function ToString() As String : Return String.Format("Country: {0}, Postcode: {1}, Town: {2}, Housenumber: {3}, Street: {4}, Firstname: {5}, Name: {6}", _Country, _Postcode, _Town, _HouseNumber, _Street, _Firstname, _Name) End Function End Class Be reminded if you do this in my code I will slowly torture you. But it can be used for fun purposes ;-).
This question came up yesterday and I decided to do a little blog post about it. Someone wanted to know if there was something like @@identity/scope_identity() for a uniqueidentifier column with a default of newsequentialid(). There is not such a function but you can use OUTPUT INSERTED.Column to do something similar. Let’s take a look First create this table USE tempdb GO CREATE TABLE bla(ID INT,SomeID UNIQUEIDENTIFIER DEFAULT newsequentialid()) INSERT bla (ID) VALUES(1) GO Do a simple select….
Having read three books written by Stephen Levy (Hackers, Crypto and Artificial Life) already I was excited that he had a book coming out about Google. In The Plex: How Google Thinks, Works, and Shapes Our Lives is a very interesting book, it is a must read for anyone who wants to know how Google thinks and why it is that it thinks that way. Both Larry Page and Sergey Brin were Montessori students, this highly influenced their way of thinking. I learned a lot of interesting stuff about Google in this book, here are a few examples:
SQL Server Management Studio is the de facto tool for working with SQL Server. But its default options may not always be the best way for you to work. After working with it for years, I’ve come up with a list of my favorite features. (Secret: This is also my way of recording this so that the next time I need to set up a new PC, I just have to come back here.)
Feelings about programming katas tend to fall into one of 3 buckets; disdain, indifference, or appreciation. The indifferent crowd generally doesn’t see what you learn from repeating the same coding exercise, while the disdainful crowd feels the same way, but at a much louder (and of course disdainful) volume. That leaves the group that feel there is value in repetitively coding the same exercise or coding numerous small code examples.