Wednesday, January 23, 2008

String.Format - the quick reference

Hello,
I just found this post very usefull for a quick reference of the formatting strings: http://idunno.org/archive/2004/14/01/122.aspx

Just post it here to keep a track ;)

Monday, January 21, 2008

PHP and .NET

Hm, recently I came to a strange site:
http://php-compiler.net/doku.php
It's an enthusiastic project to make PHP compiler for .NET and to make possible write PHP applications in the .NET environment and ASP.NET 2.0. It is still in BETA stage, but they already have Project templates for VS2005 SP1.

I shall investigate and make further posts about this one ;)

Regular Expressions

A quick search with not wasting much time just showed me this nice site: http://regexlib.com/RETester.aspx where you can test your Regular Expressions.

You might find it usefull.

Saturday, January 5, 2008

MySQL - my (Un)Favourite Database

In my last project I decided to go out with MySQL. Why - do not ask why ;)

Anyway.

In the process of building, debugging, developing I noticed that some of the searches does not return a correct result. A search in a VARCHAR field (for Cyrillic characters). I looked for the table encoding - it was UTF8; I looked for the column encoding - it was UTF8 (both collations utf8_general_ci); I looked for the server default encoding - UTF8; I looked for the encoding passed by the client application - again it was UTF8.

Suddenly, by incident I noticed - the encoding of the database was cp1251 (the Cyrillic one). It killed me.

A simple command solved the problem:

ALTER DATABASE {db_name} DEFATULT ENCODING utf8, DEFAULT COLLATION utf8_general_ci;

But I was inserting correct values, when I was browsing the table I could see the right values, but when I search for specific values in the STORED PROCEDURE with AD-HOC SQL built dynamically in the procedure, I could not get the results ...

No Idea ... but I begin to look more and more to the MS SQL server ... and its EXPRESS edition...

Friday, January 4, 2008

Network printing with VISTA and XP / print spooler hangs

Hello,
Merry Christmas and Happy New 2008 !!

So, May be you have heard a lot of "Print Spooler hangs" using Windows Vista and sharing a printer. I had a terrible couple of days looking for solution of the problem. Including online chat with HP support and posting on Microsoft TechNet forums.

Problem anatomy:

  1. Desktop station with Vista 64. HP LaserJet 1018 connected to it (have full support for VISTA 64 and print local jobs just fine, latest drivers installed from the HP site). Shared.
  2. Laptop with XP SP2 x86.
  3. Successfully browsed from the XP to the shared printer. Installed as a local printer on the Laptop using new local port (\\vista-pc\printerName).

Now, the only way I got this printer to print job from the XP is the following:

  1. In VISTA: Turn the UAC OFF.
  2. In XP: Authenticate to the VISTA with the username that is the OWNER of the printer.

Any other attempts to print (i.e. authenticate with different name, that has full access to the printer /SECURITY TAB/, or UAC ON) just sends the print job to the Queue and nothing happens until restart of print spooler service on the VISTA.

Here is the solution:
What do you need to make it work?

  1. Lots of patience;
  2. Correct drivers for correct OS (i.e. VISTA or XP) and platform (i.e. x86 or x64)
  3. First install the printer locally and make sure everything's fine (note: there are still number of printers that currently do not have VISTA drivers)
  4. Share the printer

The tricky part - change the following policies in the VISTA host:

  1. Local Computer Policies\Administrative Templates\Printers:
    Allow print spooler to accept client connections > to enabled
  2. User Configuration\Administrative Templates\Control Panel\Printers:
    Point and Print Restrictions > to disabled

Note: To change local policies you can click the "START" and then in the search box type in: gpedit.msc

The drivers part - install the additional drivers on the VISTA box:

  1. On your VISTA box open printer and faxes
  2. right click blank field
  3. Run as administrator
  4. Server Properties
  5. Drivers Tab
  6. Add the additional drivers (i.e. x86 drivers or x64 drivers)

The next trick (optional if the above scenario still does not solve the problem):

  1. Again open printers and faxes on your VISTA
  2. Locate the installed printer
  3. Right click
  4. Run as administrator
  5. Properties
  6. Ports tab
  7. UNCHECK the "Bidirectional support" checkmark
  8. Apply
  9. OK

The funniest:

  1. Go to the client (that will use the shared printer)
  2. Open Printers and faxes
  3. Right click on an empty space
  4. Add printer
  5. Choose add LOCAL PRINTER and UNCHECK the "Automatically detect plug & play printer connected ..."
  6. Choose to Create a new port
  7. Choose Local port
  8. The port name - be very careful, the name should be as follows: \\VISTA-PC-NAME\Shared-printer-name
  9. Next
  10. Choose the type of the printer (at that point you must have the appropriate drivers for the that printer)
  11. Finish the installation of the printer

Voila!
Hope this will work out for you.

The original forum posts are here:
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2629862&SiteID=17