So every once in a while I find that I have some duplicate records in my database as a result of testing or development or plain oversight. How to remedy the situation?
Well, its as easy as this simple SQL.
from YOURTABLENAME sourceTable, YOURTABLENAME compareTable
where sourceTable.fieldWithDuplicatesToMatch= compareTable.fieldWithDuplicatesToMatch
and sourceTable.PrimaryKey > compareTable.PrimaryKey
Basically, replace YOURTABLENAME with the name of your table.
Replace fieldWithDuplicatesToMatch with the field on the table that has the duplicates. Such as SKU or Email.
Replace the PrimaryKey with the table PrimaryKey or a time stamp (DateTime) field or whatever you want to use as the basis for which record to keep.
Voila! Duplicates be gone.
So….I finally decided to release my alpha version to all you hooligans who want to see whats under the hood of fellow .NET’ers applications. You can use .NET Illuminator to see all the UI objects in another .NET application and even manipulate them. Yes, pretend like you are in Visual Studios Form Designer and just start viewing and changing properties.
You can also view all connection strings the application has used to any SQL servers.
I will post more when I add more. Happy hacking!
Click here for .NET Illuminator Page
So…I was trying to add a computer to the domain today, a VM image, and continually got the error code 1355. What was seemingly a confounding issue turned out to be just a can’t find domain controller issue.
I changed the VM image to use bridged (direct connect) and reset the connection in the machine to reconnect and voila! The computer successfully connected.
Looking over the stock today (Sep 1 2009), I noticed a deeply disturbing trend. The entire market seems to retreating from the strong rally we have all so much enjoyed. The price of the stocks I follow fell by 5 -20% today alone. CitiGroup (C) fell by 9.2% to $4.54 which is a far drop from a few days ago when it was in the mid $5’s. Bank of America (BAC) fell to $16.46, a 6.42% drop in value. Freddie Mac (FRE) and Fannie Mae (FNM) both dropped by 17%, almost in harmony. A-Power (APWR) fell another 2.68% and the rediculously overpriced AIG fell over 20% down to $36.00 flat.
September is generally a crappy month for investing, but heres to hoping it gets better.
It seems to be every day or so I try and RDP into my virtual server I have hosted at GoDaddy, and the thing just decides I shouldn’t be allowed to connect. It’s a wonderful feeling to know you can see your pages being server, processes still active, but the RDP connection just gets instantaneously rejected. If I had but a clue why this happens, but I chalk it up to their proprietary virtual server quirks.
One of these days they will get their act together and I won’t have to issue a reboot request every time I want to terminal in.
UPDATE: So after talking with the GoDaddy folks, I find out that they have a single license for the virtual servers. Only one connection is allowed in at a time. When you are used to Windows normal 2 connections, this is pretty annoying. If your connection drops and you try to reconnect, it doesn’t always honor the reconnect. It sits in some sort of limbo and blocks up the port. The only way to fix it is to reboot the server. Fun, right?
If you want to avoid this, just make sure you log off after every session. Start ->Logoff. Not the lovely Red X, that just disconnects you leaving the session logged on.
I have been following Citigroup (C), Freddie Mac (FRE), and Fannie Mae (FNM) lately and it seems they are behaving very erratic.
Citigroup we all know has been a roller coaster ride for us all. A day traders dream for the brave and a scary white-knuckled ride for us long term folks. Citigroup has been slowly but surely rising higher and higher. They peaked at $5 on the 24th and I got pretty excited but then it decided to drop back down to the mid $4’s. The housing market is supposedly doing better according to this weeks report and you would have thought that the financial’s would be bolstered by the good news.
Freddie Mac and Fannie Mae have jumped 40+% in the last couple of days. Any rhyme or reason? Nope….Will it continue to rise, I sure hope so but don’t see any real reason for it to any time soon.
I keep wanting to jump into the market and grab a few more stocks, but the volatility is so high that it is quite scary for a laymen investor like myself. If anybody out there knows what the secret is, I am happy to hear it! Otherwise, I will keep watching in wonder as stocks bounce around based on consumer whim.
This is one roller coaster that can make your wallet fall out.
I was out swimming in the data pool and I started thinking to myself, how many people are sharing the same pool without me even knowing they are there? How did I even get into the pool? And why is the water so cold?
Well, if you are using ADO.NET with SqlConnection , you are playing in the pool to. ADO.NET is a pretty smart animal. It realizes that if you are going to be connecting to a database a lot, then its probably a good idea to keep the connection to the database server open awhile. It does this behind the scenes, so when you create multiple data connections, it only really grabs one from the available pool of connections and uses those.
So….with that in mind, I started thinking about how I can tell what data connections an application has used and who is swimming in my pool. Coupling that with the brainstorming involved in .NET Illuminator, I came up with a very nice and simple piece of code that grabs all the connection strings from the Pool and throws them in rafts for you to see.
Why might this be handy for .NET Illuminator, well…Its always interesting to see what data connections an app has made and what the connection string is for them 🙂
Here is my simplistic example of using C# with .NET to walk the SQL pooled connections and return their connection strings.
/// Loads all pooled connection strings.
public static List<string> LoadAllPooledConnectionStrings()
SqlConnection connection = new SqlConnection();
FieldInfo connectionFactory = connection.GetType().GetField("_connectionFactory", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Static);
object cFactory = connectionFactory.GetValue(connection);
FieldInfo connectionPoolDictionary = connectionFactory.FieldType.GetField("_connectionPoolGroups", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
object dictPools = connectionPoolDictionary.GetValue(cFactory);
Type poolDictionaryType = dictPools.GetType();
PropertyInfo pooledKeys = poolDictionaryType.GetProperty("Keys", BindingFlags.Public | BindingFlags.Instance);
object keys = pooledKeys.GetValue(dictPools, null);
List<string> allKeys = new List<string>();
foreach (object key in (IEnumerable)keys)
So…What did we learn? Just because you don’t see the pool….smell the chlorine…or even get wet, you open a data connection and you have jumped all the way in.. and left your stench behind in the water..
So..I have been thinking for quite some time, “Gee, wouldn’t it be nice to have a nice and easy to use timer class built right into the framework?”. I decided to go and use the lovely Stopwatch class to start building a lot of timing routines into my applications for debugging and logging purposes. The syntax was so easy and beautiful.
var sw = new System.Diagnostics.Stopwatch()
Can’t get much simpler than that, right? Well…..that is if the stopwatch returned reliable results….
It seems on one our computers we run this code and a 23 second process returns 10.5 seconds…Yeah, same thing I thought.. What a bunch of crap!
So, I read something about Processor Affinity and CPU clock stepping that may be causing the issue. Either way, I don’t want to have to set the threads processor affinity or try and manage the CPU’s frequency just to take a simple time measurement……Back to the old
DateTime start = DateTime.Now();
TimeSpan elapsed = DateTime.Now() - start;
I know…not much difference, but didn’t the Stopwatch look so much cooler?
I began thinking more and more about writing an application that is able to “illuminate” another .NET process. Basically, I want to be able to inject some code into another .NET application and then provide the ability to see all of the user controls and Forms loaded in the application as objects that can be manipulated.
I am working on creating the application that will shove itself in there and let you see every active control and Form and let you manipulate the properties of them all realtime. Make the button active. Show the hidden panel. Change the text on a label for your own amusement.
It should be ready in the next few days, so stay tuned for .NET Illuminator…
Welcome to the random musings and ramblings I have decided to grace the web with. I will be using this platform to help disseminate knowledge that I have picked up along the way as well as to keep a record of things I will probably forget.
Thanks for stoppping by and I hope to see you again soon.