If you require to open multiple connections several times in your application, it is not a good practice to open the connection every time it's needed because it involves overhead. For overcoming this problem, connection pooling is used. Whenver you close the connection, you mean to destroy the connection object because your work is already done. But, @ the backend, OLEDB preserves it's state in a pool. So whenver you will need the connection again, ADO will not have to do the expensive stuff again to make a connection to the source. Rather, it will pick the connection from the pool and will return the connection object.
Please note that the connection pooling can only be achieved when the connection information is same. If you are opening a connection with a new ID/password, ADO will open a new connection to avoid security issues.
Thanks,
Vikas
Wednesday, May 21, 2008
Friday, April 4, 2008
Some ADO Fundamentals
Hi,
We all are using ADO quite frequently, but we are not sure if we are using it efficietnly too or not. I have given some information below, which may help you out in managing your queries.
While getting a recordset from a connection object.
Set objRS = objConn.Execute(CommandText, [RecordsAffected],[Your Options])
You can speed up your records fetching process by mentioning the options in the recordset object. Following are the options which are available:
You can also add the following ExecuteOptionEnum modifiers to Options:
adAsyncExecute, for asynchronous execution.
adAsyncFetch, for asynchronous fetching.
adAsyncFetchNonBlocking, for asynchronous fetching that does not block.
adExecuteNoRecords, for a non-row returning command.
Thanks,
Vikas Bhandari
We all are using ADO quite frequently, but we are not sure if we are using it efficietnly too or not. I have given some information below, which may help you out in managing your queries.
While getting a recordset from a connection object.
Set objRS = objConn.Execute(CommandText, [RecordsAffected],[Your Options])
You can speed up your records fetching process by mentioning the options in the recordset object. Following are the options which are available:
| adCmdText | If you have given the Command Text as a SQL string. |
| adCmdTable | It is a sign that query would return the column names of the table. |
| adCmdTableDirect | for a table name, whose columns are all returned. |
| adCmdStoredProc | for a stored procedure name. |
| adCmdFile | for a saved recordset. |
| adCmdUnknown | for an unknown command type. |
| adCmdUnspecified | to indicate the command type is unspecified. ADO will work out the command type itself, but this will lead to poorer performance, so you should always explicitly set the command type. |
You can also add the following ExecuteOptionEnum modifiers to Options:
adAsyncExecute, for asynchronous execution.
adAsyncFetch, for asynchronous fetching.
adAsyncFetchNonBlocking, for asynchronous fetching that does not block.
adExecuteNoRecords, for a non-row returning command.
Thanks,
Vikas Bhandari
Creating Custom Menus in Excel through VBA
Source :
http://www.ozgrid.com/VBA/custom-menus.htm
http://www.ozgrid.com/VBA/custom-menus.htm
Sub AddMenus()
Dim cMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCutomMenu As CommandBarControl
'(1)Delete any existing one. We must use On Error Resume next _
in case it does not exist.
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("&New Menu").Delete
On Error GoTo 0
'(2)Set a CommandBar variable to Worksheet menu bar
Set cbMainMenuBar = _
Application.CommandBars("Worksheet Menu Bar")
'(3)Return the Index number of the Help menu. We can then use _
this to place a custom menu before.
iHelpMenu = _
cbMainMenuBar.Controls("Help").Index
'(4)Add a Control to the "Worksheet Menu Bar" before Help.
'Set a CommandBarControl variable to it
Set cbcCutomMenu = _
cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
Before:=iHelpMenu)
'(5)Give the control a caption
cbcCutomMenu.Caption = "&New Menu"
'(6)Working with our new Control, add a sub control and _
give it a Caption and tell it which macro to run (OnAction).
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Menu 1"
.OnAction = "MyMacro1"
End With
'(6a)Add another sub control give it a Caption _
and tell it which macro to run (OnAction)
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Menu 2"
.OnAction = "MyMacro2"
End With
'Repeat step "6a" for each menu item you want to add.
Creating Custom Menus in Power Point
A very good link to learn about Powerpoint.
http://www.bettersolutions.com/powerpoint/PBZ143/LE824411712.htm
Thanks,
Vikas
http://www.bettersolutions.com/powerpoint/PBZ143/LE824411712.htm
Thanks,
Vikas
Subscribe to:
Posts (Atom)