I acquire consistently admired to assay adapted brands of swiss fake watches affluence watches. If comparing the above brand, there are replica watches uk not abounding differences you can accretion distant from the above of replica rolex uk the replica. You can accretion some of the best Patek Philippe replica watches and acquire abolishment to rolex replica say added than your architectonics or you could accretion bigger above and a lower replica hublot watches casting and achieve your best easier.

Currently browsing Uncategorized posts — Visual Basic Feng Shui

Category Archives: Uncategorized

Vista, XP, SQL Server 2005, Workgroups and Connections

1
Filed under Uncategorized

Whew! The title says it all.

imageI recently had a little problem with my server. Notice the 3 blown caps.

I had my 5 year old daughter take a look. Without pointing out anything in particular, I asked her “Ok, this computer isn’t working right. Any idea why?”

She looked around with a flashlight for about a minute and states “Those 3 batteries look like they’ve gotten dirty. Maybe you need to clean then up?”<g>

So, I’ve got no server as of now.

Fortunately, all my SQL databases I use for testing get backed up every night, so I still have them all. Unfortunately, the SQL Server installation itself was on that blown machine<sigh>.

I’d been wanting to virtualize my server for some time now, so this was the perfect opportunity. I fired up VMWare, cloned an existing XP VM I often use for testing, cleaned it up, put SQL Server 2005 on it, ran the SQL SP2 update, then restored all my DB backups. No problem.

With the VM running on my workstation, I loaded SQL Server Management Studio on my workstation and tried to connect to the virtual server.

image

(for search purposes, the message is “Login failed for user ‘argos\guest’. (Microsoft SQL Server, Error: 18456)”)

Hmm. I was pretty sure I had things set up right. So I tried SQL Authentication with the SA user and password.

I’m in.

Ok. That’s odd. And why is it trying to connect me as guest? Wait… Originally, my server was running Win2003 Server, so it had DNS setup. With it gone, I’m in workgroup mode. Ah! I didn’t have matching user accounts on this new virtual server and on my workstation. Set up a matching account, and try a remote connection request to the SQL Server from my workstation. Still no dice.

I checked the SQL ERRORLOG file (you can typically find it in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG), and I end up with this:

2009-02-05 16:11:36.36 Logon       Error: 18456, Severity: 14, State: 11.
2009-02-05 16:11:36.36 Logon       Login failed for user ‘ARGOS\Guest’. [CLIENT: 192.168.100.110]

That STATE number is the key. A state of 11 means “Valid login but server access failure” (There’s a really good table of error states here).

That was the clue I needed. After way too much googling, scratching my head and trying random things, I eventually came across this post by Jens Suessmeyer.

The short of it is that, under XP anyway, if you are running in a workgroup (ie non-domain) and you have Simplified File Sharing turned on, this will cause SQL Server to ALWAYS force remote authentication requests to fall back to the Guest user. It was only after I’d found the above post that I came across this MSKB article that describes the problem in more detail.

So, it’s off to the Folder Options dialog, I uncheck the Use Simple File Sharing option:

image

And, no more connection failures!

So, to sum up. If:

  1. You’re using SQL Server 2005 (and likely other versions as well).
  2. You’re running in a WORKGROUP environment
  3. You need or want to use WINDOWS AUTHENTICATION and not just SQL Authentication
  4. You set up a login on your server and your remote machine that exactly match in username and password
  5. You’ve enabled SQL Ports 1433 and 1434 through your firewall.
  6. You can connect via Windows Auth just fine when you run SQL Management Studio from the server
  7. BUT you get a connection error indicating that your trying to connect as GUEST, when you were expecting to connect as your current username.

Then you most likely need to turn OFF Simple File Sharing on the SQL Server machine.

Changing the Windows XP Product Key

0
Filed under Uncategorized

I was working with a quite old inherited virtual machine today (VMs have a nasty habit of getting old and unpatched), and I needed to have SP2 (actually XP SP3 is out now) on it (to install SQL Express, among other things).

The problem was, this VM had a installation of XP, no service packs, using a product key who’s ancestry was, shall we say, questionable, at best.

Of course, I have several valid product keys from MSDN subscriptions, so I’m completely legit. But I needed to get this VM squared up so I could get products installed on it.

In the past, I’ve used a technique I found online whereby you edit a registry entry to invalidate your current activation (and thus force Windows to want to reactivate itself), then you run the msoobe.exe application with a certain command line to relaunch the activation process. Not to hard, but it didn’t work with my legitimate WinXP product keys. I have no idea why not, and there was nothing in any of the messages to indicate what was wrong.

Then I happened across a link to the Windows Product Key Update Tool.

A quick download and it worked perfectly. It properly accepted the product key for XP from my MSDN subscription, updated Windows and reactivated it straight away.

Certainly, a very handy tool to have in the stable!

XAML editor crashes Visual Studio 2008 SP1

0
Filed under Uncategorized

A week or so ago, I decided to try my hand at a little XAML, so I loaded up VS2008, started up a simple project and created a few forms (or whatever they’re called in WPF speak).

Anyway, I hadn’t gotten but maybe 10 minutes in when VS crashed. Hard crash. No error message, or dialog of any sort, just closed out.

I reloaded the project and tried again. Immediate crash as soon as I loaded up any XAML file.

I let it sit over Thanksgiving (I believe it’s always good to give a system a chance to think about what it’s doing before you really lay into it<g>) and tried again today.

No joy.

So I started researching the issue and came across a pretty active thread about just this problem.

Long story short, uninstall Power Commands for Visual Studio 2008 if you’ve got it installed and have VS2008 SP1. It doesn’t look like PowerCommands has changed since April and there definitely seems to be issues with it and SP1.

Compressing Memory Streams

0
Filed under Uncategorized

One thing that has definitely taken some getting used to (for me anyway) in VB.NET is the whole concept of streams.

I like the idea, generally, but I was working through some code to stream debugging info into a resource in an already compiled EXE file when I ran into a problem with decompressing the resource data.

It just wouldn’t decompress properly.

After backtracking and puzzling over it, I discovered that the problem was actually in the compression phase.

   Private Function pCompressStream(ByVal UncompressedStream As MemoryStream) As MemoryStream
      Dim CompressedStream As New System.IO.MemoryStream()
      Using GZip As New System.IO.Compression.GZipStream(CompressedStream, System.IO.Compression.CompressionMode.Compress)
         GZip.Write(UncompressedStream.ToArray, 0, UncompressedStream.Length)
      End Using
      Return CompressedStream
   End Function

Note the Dim GZip line? If you look at the overloads, there’s a possible 3′rd option, LeaveOpen. It defaults to false.

From what I can tell, if you connect a GZipStream up to a FileStream, there’s no need for this parameter. When the GZip closes, the file is closed and on you go.

But, with MemoryStreams, it’s quite unlikely that you’d want to close the resulting output memory stream after zipping data into it.

But that’s exactly what happens if you don’t set LeaveOpen to True.

What’s worse. You need to Close the GZipStream before reading that MemoryStream(either by using a USING block as I have, or by calling Close directly). If you don’t, garbage collection might not happen for some time and the final data in the internal GZip buffers won’t get written to your memory stream, resulting in only partial compressed data, which definitely won’t decompress properly!

All this is likely old hat to grizzled .NET heads, but if you’re like me and coming from an extensive VB6/assembler background, it can certainly causing some headscratching for a bit.

Slow Vista Copying and Deleting

0
Filed under Uncategorized

image Like a lot of people out there, I’ve been bitten by the Vista “Slow Copy/Delete” bug many many times myself.

I finally decided I’d had enough today and when looking for a solution.

I came across a couple of posts discussing a hotfix available from Microsoft, but it’s apparently not that easy to get a hold of, and its a questionable fix at that.

Then I happened across a short post in a SlashDot discussion that mentioned turning off thumbnails in the Explorer view.

I’ve never heard of that one, so I gave it a quick shot.

First, open the Folder Options:

image

Then, just make sure the first option “Always Show Icons, never thumbnails” is checked:

image

Surprisingly, this does seem to a have a pretty dramatic effect on the copying and deleting processes, as well as noticeably speeding up the time it takes to get from a right-click to actually seeing the right click context menu in Explorer. It’s still not instant like it should be, but it’s better than before.

I’ll keep playing with it and post if I discover any other interesting bits about this seemingly easy workaround.

Fixing System.String, part 2

0
Filed under Uncategorized

I talked about fixed the IsNullOrEmpty method on the string object here.

But another aspect of the string object that has irritated me for a while is the Length property.

Obviously, the Length property returns the length of the current instance of a string variable.

However, because it’s an instance property, it can only be invoked against variables that have actually already been initialized to some value.

If you try and run this code, you’ll get an Object Not Set error when you execute the second line:

dim s as string
debug.print s.Length

Now, anybody that’s coded in VB intuitively knows that an unitialized string has a length of 0, and such a request should certainly  not result in throwing an error. It doesn’t matter one whit whether this is technically incorrect or not. I my book, those issues are for the compiler to work out, NOT the programmer.

Since the string class is an intrinsic type and we really can’t inherit from it or extend it in any traditional way, is there any way to correct this gaff?

With VB 2008, there is.

I blogged a bit about extension methods in the previous mentioned post and that’s what I’ll use to fix the Length property as well.

Unfortunately, as I also mentioned in my previous post, Length is a property  and not a method, so you can’t create an extension method for it directly, which is a shame.

However, long time VB programmers don’t think to use “Length” anyway, you always retrieved the length of  string via LEN(stringname), and LEN is not a member of the string object.

So, just add the following to a module to your application:

Imports System.Runtime.CompilerServices

Module StringExtensions

    ''' <summary>
    ''' Returns length of the string or 0 if the string is empty or has never been assigned (is nothing)
    ''' </summary>
    ''' <param name="aString"></param>
    ''' <returns></returns>
    <Extension()> _
    Public Function Len(ByVal aString As String) As Integer
        Return Microsoft.VisualBasic.String.Len(aString)
    End Function
End Module

and you’ll have a LEN function available directly from any string variable that will work regardless of whether the variable is initialized or not.

Also, note the <summary> comment. This will be displayed by Intellisense in the IDE, which can be quite handy.

image

And finally, you can’t use Return Len(aString) in the function, because doing so would be treated as a recursive call to the Len Extension method itself! Thus, I fully qualify the call to the Microsoft.VisualBasic.Strings LEN function.

All of this begets the obvious next question, “Why not just use Len(stringvar)“?

To which, I have no good answer.

Maybe it’s just a .NET thing<g>

TurboTax no longer includes a free E-File

0
Filed under Uncategorized

image I realize this is a little late, and almost totally off topic from Visual Basic, but it is a peculiar business decision, if you ask me, which, in a way, has to do with developing VB apps.

Intuit has decided, according to their support staff, that as of this year, if you purchase the CD version or download version of TurboTax (ie, the fat client), you no longer get a single E-FILE for free. You have to pay an extra 17.95 for that privilege.

Now, TurboxTax has always been a pretty good deal in my book, but with the competition in the marketplace now, I can’t see how this is possibly a good idea, other than possibly to drive business to their online offering, which does still offer a free E-File.

Oddly, though, the online version doesn’t have the same “FORMS” mode that the fat client does, thus you can ONLY use their “interview” style format to enter data, which can be cumbersome in many cases. Hence, the two aren’t interchangeable.

I suppose to their credit, they did offer to refund the E-File charge when I complained about it. But by the time their support emailed me back, I’d already printed and mailed my return.

Yet one more reason that FairTax seems more and more like a better idea.

Go there, check it out, and if you agree, and sign the petition.

HyperTerminal and Vista

0
Filed under Uncategorized

Ok. Yet one more reason to dislike Vista.

Granted, I don’t regularly use HyperTerminal, but when you need to hack at some AT commands, well, it sure was handy to have around.

And it’s been there ever since, what, Windows -1?

But alas, no more.

So, off on the hunt I go. Now, I’ve known about puTTY for quite some time, but I always thought it was a telnet/TTY client. But much to my surprise, it just relatively recently got an upgrade with direct serial access under Windows.

image

I gotta say, for dinking around with your typical modem setup, this new puTTY honestly seems to work far smoother than HyperTerminal ever did.

C’est la vie, HyperTerminal. May you rest in peace.

Quick Find in VS2008, Not So Much

0
Filed under Uncategorized

It looks like I’m not the only person experiencing absolutely terrible performance in VS 2008 when performing what is ostensibly known as a “Quick Find”

image

This is the dialog you normally get when you do a Quick Find (Ctrl-F).

Note that I typically have it set for Entire Solution, Hidden Text and Use Wildcards.

With things set up this way, on a Core 2 Dual Core machine, I typically see a 2-4 second delay when I click the Find Next button. Pressing F3 to continue the find yields similar times.

And this is when the next occurrence is on the same line of code as the current occurrence!

Not much of a “Quick Find” in my book.

I tried all the various options, and nothing has any effect EXCEPT for the “Look In” option. If I change it from Entire Solution, to, well, anything else, the finds are then instantaneous.

If anyone knows of the cause or solution, I’d love to hear about it. So far, I’ve turned up bupcus on this one.

Till then, the Find In Files (Ctrl-Shift-F) option seems to be the best alternative.

Office File Formats Released

0
Filed under Uncategorized

Microsoft has just recently (as of Feb 15) released the full specs on the various Office file formats (including Word DOC files, Excel XLS files and Powerpoint PPT files, in particular).

The specs are available here.

If you’re a file format geek, or your job actually revolves around manipulating these types of files, this is surely a welcome addition to your arsenal.

Some of this information has been available, more or less, for quite some time. Most everyone who’s interested knows, for instance, that these files are actually OLE structured storage files, essentially entire “mini file systems” unto themselves.

But much of the detail has been sketchy at best, till now.

One word of warning though. Don’t expect these to be simple, cookbook recipes on rolling your own version of Word or Excel. The specs are huge and the formats unbelievably complex, having evolved over the course of 10 or more years. Further, these are not Web 2.0, nice, friendly XML/HTML/Text/human readable files by any stretch. They’re tangled, binary, pointer-ridden globs of structures that take a good deal of code just to render somewhat intelligible.

That said, official documentation is far better than none, and surely beats reverse-engineering the formats, as has been done up to this point.

I know I’ll be digging into this more in the coming weeks.

Happy hacking!