From the 2008 version of Visual Studio, VSTO (Visual Studio Tools For Office) was included as started in all versions from Professional upwards. Previously it had been a separate add-in, with limited functionality in the pro version of Visual Studio.
To create an add in for Outlook 2007;
1) Oen visual studio 2008, go to File\New Project
2) From the project tree Choose Visual Basic\Office 2007\Outlook Add In
3)
4) To add an event handler, select Application from the drop down on the left, which lists elements of the class. Then select the event from the event list on the right.
5) Take as an example, ItemSend event
6) Add some code to the item event
7) Run the project in the usual Visual Studio way, Outlook will start, and the add in will be installed, so if you try to send an email message, your event will fire.
8) One great thing here is that you can set breakpoints within the code in Visual Studio, and do the usual debugging, while events are being fired in Outlook. This is an advance over the VBA methods of older versions of Outlook.
9) To remove the add-in from Outlook during the development stage: in Visual Studio Debug: Clean
Andrew Mogford's Notes on MS SQL Server, the Microsoft .Net Framework development and other related matters that I have come across in my work for Kandy Solutions and other software houses. My company Kandy Solutions's web site
Tuesday, 12 October 2010
Thursday, 7 October 2010
Janus GridEx - Adding a button Column
When using a Janus GridEx control it can be useful to have a column with a button in it.
This is an example of how to add a button column to a grid:
Dim ButtonCol As New Janus.Windows.GridEX.GridEXColumn
ButtonCol.Key = "Add" 'This is the way to identify the column when it is clicked
ButtonCol.ButtonText = "Add" 'the caption on the button
ButtonCol.ButtonDisplayMode = CellButtonDisplayMode.Always 'The button is visible even if the row is not selected
ButtonCol.ButtonStyle = ButtonStyle.ButtonCell
ButtonCol.Width = 40
GridEX1.RootTable.Columns.Add(ButtonCol)
And, how to respond to the button click event:
Private Sub GridEX1_ColumnButtonClick(ByVal sender As Object, ByVal e As Janus.Windows.GridEX.ColumnActionEventArgs) Handles GridEX1.ColumnButtonClick
If e.Column.Key = "Add" Then 'Add should be replaced with the key to the button column
'To pick up the value of a specific cell in the current row, for example to get the record ID
CInt(GridEX1.GetRow(GridEX1.Row).Cells("Id").Text)
'put handling code here
End If
End Sub
This is an example of how to add a button column to a grid:
Dim ButtonCol As New Janus.Windows.GridEX.GridEXColumn
ButtonCol.Key = "Add" 'This is the way to identify the column when it is clicked
ButtonCol.ButtonText = "Add" 'the caption on the button
ButtonCol.ButtonDisplayMode = CellButtonDisplayMode.Always 'The button is visible even if the row is not selected
ButtonCol.ButtonStyle = ButtonStyle.ButtonCell
ButtonCol.Width = 40
GridEX1.RootTable.Columns.Add(ButtonCol)
And, how to respond to the button click event:
Private Sub GridEX1_ColumnButtonClick(ByVal sender As Object, ByVal e As Janus.Windows.GridEX.ColumnActionEventArgs) Handles GridEX1.ColumnButtonClick
If e.Column.Key = "Add" Then 'Add should be replaced with the key to the button column
'To pick up the value of a specific cell in the current row, for example to get the record ID
CInt(GridEX1.GetRow(GridEX1.Row).Cells("Id").Text)
'put handling code here
End If
End Sub
Wednesday, 6 October 2010
Error Handling in SQL Server 2005, obtaining Error Message
One of the features that came into SQL 2005 was the use of Try..Catch blocks.
It is good to be able to elegantly deal with errors, but usually as a developer, you still want to know that an error has occurred, and what it is. In .Net there are exception objects you can analyse. SQL Server is different, but it is still possible to access information about the error condition.
This syntax can be used in stored procedures, but sadly not in functions, which don't support try..catch blocks in SQL Server 2005.
BEGIN TRY
STATEMENT BLOCK
END TRY
BEGIN CATCH
READ THE ERROR, IF RUNNING THE SPROC IN A QUERY WINDOW, YOU WILL BE
ABLE TO SEE THE ERROR IN THE MESSAGES WINDOW
SELECT ERROR_NUMBER() ERNumber,
ERROR_SEVERITY() Error_Severity,
ERROR_STATE() Error_State,
ERROR_PROCEDURE() Error_Procedure,
ERROR_LINE() Error_Line,
ERROR_MESSAGE() Error_Message
PUT ERROR HANDLING CODE HERE
END CATCH
It is good to be able to elegantly deal with errors, but usually as a developer, you still want to know that an error has occurred, and what it is. In .Net there are exception objects you can analyse. SQL Server is different, but it is still possible to access information about the error condition.
This syntax can be used in stored procedures, but sadly not in functions, which don't support try..catch blocks in SQL Server 2005.
BEGIN TRY
STATEMENT BLOCK
END TRY
BEGIN CATCH
READ THE ERROR, IF RUNNING THE SPROC IN A QUERY WINDOW, YOU WILL BE
ABLE TO SEE THE ERROR IN THE MESSAGES WINDOW
SELECT ERROR_NUMBER() ERNumber,
ERROR_SEVERITY() Error_Severity,
ERROR_STATE() Error_State,
ERROR_PROCEDURE() Error_Procedure,
ERROR_LINE() Error_Line,
ERROR_MESSAGE() Error_Message
PUT ERROR HANDLING CODE HERE
END CATCH
Check if Global Temp Table Already Exists in SQL Server 2005
One problem with using Global temp tables in SQL Server, (those indicated by a double hash symbol at the beginning of their name), is that a procedure fails to remove them, the next time they are created you will get an error because they already exists.
To test for their existence before creating them in SQL Server 2005 I used this code, replace ##temp with your table name of course
IF NOT EXISTS(select * from tempdb.sys.sysobjects where name = '##Temp')
BEGIN
code to create ##temp
END
ELSE
BEGIN
truncate table ##temp
END
To test for their existence before creating them in SQL Server 2005 I used this code, replace ##temp with your table name of course
IF NOT EXISTS(select * from tempdb.sys.sysobjects where name = '##Temp')
BEGIN
code to create ##temp
END
ELSE
BEGIN
truncate table ##temp
END
Sunday, 3 October 2010
Virtual PC Network Settings With Wireless Adapter
I created a Windows XP virtual PC in Microsoft Windows Virtual PC 2007 and needed to get it to connect to the internet for updates and authentication.
The host PC was connected to the internet via a wireless connection.
This are the steps I took to get this working successfully.
In the virtual machine settings, in the Networking section, I selected the wireless adapter from the list.
See screenshot
Then on the virtual machine I went to Control Panel, networking, and configured the local connection settings to match those in the host machine. Since I was using manually assigned IP addresses I made sure the ip address itself was the same as the host, but everything else, matched the host's configuration.
The virtual machine could now communicate over the internet.
To connect to a Windows Domain, make sure the DNS address in the network adapter properties is the IP address of the Domain Controller. I have found that having an alternate DNS address here, even as the number 2 can prevent the VM joining the domain.
The host PC was connected to the internet via a wireless connection.
This are the steps I took to get this working successfully.
In the virtual machine settings, in the Networking section, I selected the wireless adapter from the list.
See screenshot
Then on the virtual machine I went to Control Panel, networking, and configured the local connection settings to match those in the host machine. Since I was using manually assigned IP addresses I made sure the ip address itself was the same as the host, but everything else, matched the host's configuration.
The virtual machine could now communicate over the internet.
To connect to a Windows Domain, make sure the DNS address in the network adapter properties is the IP address of the Domain Controller. I have found that having an alternate DNS address here, even as the number 2 can prevent the VM joining the domain.
Friday, 1 October 2010
"" is not a valid login error message when installing SQL Server 2008 Express
When trying to install MS SQL Server Express 2008 onto a Windows XP machine we received the following error message during the later stages of installation.
The message appeared late during the installation, at the stage where it asked which account to run the various SQL services under. The solution was odd, the server name and the user name were the same. Changing either caused the problem to disappear.
The message appeared late during the installation, at the stage where it asked which account to run the various SQL services under. The solution was odd, the server name and the user name were the same. Changing either caused the problem to disappear.
Subscribe to:
Posts (Atom)