Friday, 16 March 2012
How to find Datasource from Connection String?
To find Connection String parameters, just use it one of its method as below
return new OledbConnectionStringBuilder(ConnectionString).DataSource;
Simple and effective way to get the value..
Thursday, 5 August 2010
"HTTP Error 404 - File or Directory not found" error message when you request dynamic content with IIS 6.0
To permit IIS to serve dynamic content, the administrator must unlock this content in the Web service extensions node in IIS Manager. To do this, the administrator must either enable a pre-existing Web service extension or add a new Web service extension.
Enable a Pre-existing Web Service Extension in IIS 6.0
To permit IIS to serve content that requires a specific ISAPI or CGI extension that is already listed in the Web service extensions list, follow these steps:
- Open IIS Manager, expand the master server node (that is, the Servername node), and then select the Web service extensions node.
- In the right pane of IIS Manager, right-click the extension that you want to enable. In this example, this is Active Server Pages.
- Click to select the Allow check box.
Add a New Web Service Extension to IIS 6.0
To permit IIS to serve content that requires a specific ISAPI or CGI extension that is not already listed in the Web service extensions list, follow these steps:
- Open IIS Manager, expand the master server node, and then select the Web service extensions node.
- In the right pane of the IIS Manager, click Add a new Web service extension under Tasks.
- In the Extension name box, type a friendly name for the extension that you want to add (for example, FrontPage Server Extensions).
- In the Required files box, click Add, and then select the path and the name of the file that will handle requests for the specific extension. After you select the path and the file name, click OK.
- If the extension must be enabled immediately, click to select the Set extension status to allowed check box.
- Click OK to save your changes.
For more information, please refer to http://support.microsoft.com/kb/315122
Tuesday, 29 June 2010
How to view line numbers in VB.NET
Remember line numbers ??? Long time ago, they were used to branch them with a ‘Go To’ statement. And it is still available with Visual Studio 2008 and pretty useful for error handling too…
For example, a lot of error messages give you specific line numbers in your code to use to find the errors. Trying to count down the page manually can be pretty tedious.
To enable line numbers, go to
Tools menu item > Options > Text Editor > Basic > General
Click the checkbox in front of "Line Numbers". It should do it…
Friday, 25 June 2010
Stopping a form closing using vb.net
Quick and useful tip..
Private Sub MyForm_Closing(ByVal sender As System.Object, ByVal e As _
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
Select Case MessageBox.Show("Are you sure you want to close this window?", _
"Your application", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Case MsgBoxResult.Yes
'Do Nothing
Case MsgBoxResult.No
e.Cancel = True
End Select
Catch ee As Exception
Throw ee
End Try
End Sub
Thursday, 24 June 2010
Iterating through a Dictionary Object's Items in VB.NET
Good example for iterating through dictionary object…
Dim DictObj As New Dictionary(Of Integer, String)
DictObj.Add(1, "ABC")
DictObj.Add(2, "DEF")
DictObj.Add(3, "GHI")
DictObj.Add(4, "JKL")
For Each kvp As KeyValuePair(Of Integer, String) In DictObj
Dim v1 As Integer = kvp.Key
Dim v2 As String = kvp.Value
Debug.WriteLine("Key: " + v1.ToString _
+ " Value: " + v2)
Next
For more information, please refer to http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
Wednesday, 3 February 2010
Simulate Keystrokes using Win32 API (SendInput)?
Recently, I was modifying the old softphone source code (written in VB6) and encountered error using ‘SendKeys’ function. Sometimes, it sends multiple keystrokes for the same char resulting in application errors. Thought of using WinAPI’s to simulate keystrokes and got this one..works really well…
Const KEYEVENTF_KEYUP = &H2
Const INPUT_MOUSE = 0
Const INPUT_KEYBOARD = 1
Const INPUT_HARDWARE = 2
Private Type MOUSEINPUT
dx As Long
dy As Long
mouseData As Long
dwFlags As Long
time As Long
dwExtraInfo As Long
End Type
Private Type KEYBDINPUT
wVk As Integer
wScan As Integer
dwFlags As Long
time As Long
dwExtraInfo As Long
End Type
Private Type HARDWAREINPUT
uMsg As Long
wParamL As Integer
wParamH As Integer
End Type
Private Type GENERALINPUT
dwType As Long
xi(0 To 23) As Byte
End Type
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Sub SendKey(bKey As Byte)
Dim GInput(0 To 1) As GENERALINPUT
Dim KInput As KEYBDINPUT
KInput.wVk = bKey 'the key we're going to press
KInput.dwFlags = 0 'press the key
'copy the structure into the input array 's buffer.
GInput(0).dwType = INPUT_KEYBOARD ' keyboard input
CopyMemory GInput(0).xi(0), KInput, Len(KInput)
'do the same as above, but for releasing ' the key
KInput.wVk = bKey ' the key we're going to realease
KInput.dwFlags = KEYEVENTF_KEYUP ' release the key
GInput(1).dwType = INPUT_KEYBOARD ' keyboard input
CopyMemory GInput(1).xi(0), KInput, Len(KInput)
'send the input now
Call SendInput(2, GInput(0), Len(GInput(0)))
End Sub
To simulate “H” Keystroke, just call SendKey(CByte(asc(“H”))
How to multiple selected items from List Box (VB6)?
Ever wondered how to remove multiple selected items from list box in VB6? Trick here is loop through listbox in REVERSE.
Here is the sample and enjoy :-)
Dim intCount As Integer
For intCount = (lstSample.ListCount -1 1) To 0 Step -1
If lstSample.Selected(intCount) Then
lstSample.RemoveItem intCount
End If
Next
Monday, 12 October 2009
Add or Remove line numbers in Word Document
When I was preparing design document using templates, I found that having line number was useful, especially for review.
Struggled a bit to set this using Office 2007, used Microsoft help to get these details…:-)
- On the Page Layout tab, in the Page Setup group, click Line Numbers.
Note If your document is divided into sections and you want to add line numbers to the entire document, you first need to select the document. Click Select in the Editing group on the Home tab, and then click Select All. Or press CTRL+A.
- Do one of the following:
- To number consecutively throughout the document, click Continuous.
- To start with number 1 on each page, click Restart Each Page.
- To start with number 1 after each section break, click Restart Each Section.
Remove line numbers
You can remove line numbers from the entire document, from a section, or from a paragraph.
- Click in the document, or click in the section or paragraph from which you want to remove line numbers. If you want to remove line numbers from multiple sections, select the sections.
- On the Page Layout tab, in the Page Setup group, click Line Numbers.
- Do one of the following:
- To remove line numbers from the entire document or section, click None.
- To remove line numbers from a single paragraph, click Suppress for Current Paragraph.
Reference: http://office.microsoft.com/en-us/word/HP012292791033.aspx