Thursday, June 26, 2008

How can I print a web page?

Some browsers support Javascript's Window.Print() method. You can use it in the click event of a control, say a button.

<input type="button" value="Print this window" onClick="Window.Print()"/>

This will bring up a Print Dialog which is good thing since it will allow you make up your mind whether you really want to print; allows you to see if Printer is turned on, etc.


Another way would be to place a Web Browser Control on a windows form. Use the WebBrowser's navigate() method to go to the page you want at form load. Then use the click event of a button to Print.

Ofcourse you need to add a PrintDocument control from Toolbox to your form.



Code Follows:

Imports System.Windows.Forms.WebBrowser

Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load

WebBrowser1.Navigate("http://hodentek.blogspot.com/")
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

PrintDocument1.Print()

'The above will print the Form1

End Sub

End Class

Wednesday, June 25, 2008

On using the Httpcfg tool in Windows XP Professional

HTTPCFG.EXE is generally found in these locations on your computer:

C:\

or

C:\windows\Support\Tools\Support.cab

Syntax:

The next listing shows the Syntax for running this query

C:\>httpcfg query
Usage: httpcfg ACTION STORENAME [OPTIONS]
ACTION - set query delete
STORENAME - ssl urlacl iplisten
[OPTIONS] - See Below
Options for ssl: -i IP-Address - IP:port for the SSL certificate (record key)
-h SslHash - Hash of the Certificate.
-g GUID - GUID to identify the owning application.
-c CertStoreName - Store name for the certificate. Defaults to "MY". Certificate must be stored in the LOCAL_MACHINE context.
-m CertCheckMode - Bit Flag 0x00000001 - Client certificate will not be
verified for revocation. 0x00000002 - Only cached client certificate revocation will be used. 0x00000004 - Enable use of the Revocation freshness time setting. 0x00010000 - No usage check.
-r RevocationFreshnessTime - How often to check for an updated certificate revocation list (CRL). If this value is 0, then the new CRL is updated only if the previous one expires. Time is specified in seconds.
-x UrlRetrievalTimeout - Timeout on attempt to retrieve certificate revocation list from the remote URL. Timeout is specified in Milliseconds.
-t SslCtlIdentifier - Restrict the certificate issuers that can be trusted. Can be a subset of the certificate issuers that are trusted by the machine.
-n SslCtlStoreName - Store name under LOCAL_MACHINE where SslCtlIdentifier is stored.
-f Flags - Bit Field 0x00000001 - Use DS Mapper. 0x00000002 - Negotiate Client certificate. 0x00000004 - Do not route to Raw ISAPI filters.
Options for urlacl: -u Url - Fully Qualified URL. (record key) -a ACL - ACL specified as a SDDL string.
Options for iplisten: -i IPAddress - IPv4 or IPv6 address. (for set/delete only)

USAGE:
If you want to find the URLs and associated ACLs run this query on your computer.

C:/>httpcfg query urlacl

or with the u flag as in,

C:/>httpcfg query urlacl /u

Both return the same result and there will be no completed final message.

Friday, June 6, 2008

How do you specify in the ADO DataReader destination your db connection to Oracle?

Drop a ADO DataReader destination and add path from your ADO DataSource.
Right click the ADO DataReader Destinaton and in the window that pops-up click on the NEW.. button in the ADO.NET Destination Editor. In the window that pops-up click on the New...button to create a new connection manager and choose .NET Providers for OleDb\Microsoft OLE DB Provider for Oracle. Follow this up by providing the server name and authentication details.

Learn most of regular configuraion in SSIS under two weeks from my illustrated guide:

http://hodentek.blogspot.com/2008/01/about-my-new-book.html

Thursday, June 5, 2008

What can the string function StrDup() do ?

First of all StrDup() fuction is a member of the Microsoft.VisualBasic.Strings.
It comes in three flavors:

StrDup(Integer,Char) as String
StrDup(Integer, Object) as Object
StrDup(Integer,String) as String

What it returns in each case is the first character of the
string the number of times.


Say, if the string is "yes" and the integer is 7 you would get
yyyyyyy as the return value. In the case of the argument
Object, the object should be either a string or a char.

Observe the following listing:

Wednesday, June 4, 2008

I need to convert a string into a Byte Array. How do I code it in Visual Studio?

Visual Studio has Microsoft Visual Basic already referenced and you can use the following code. Of course you need to add an imports statement as shown. This code was tested using Visual Studio 2008.

In this code I am converting the string "Welcome" to a Byte array and writing it to the immediate window.

---
Code follows:


The output of this is:

87
0
101
0
108
0
99
0
111
0
109
0
101
0