Infragistics’ UltraDateTimeEditor control – Before and after value

Here is my solution to access the before and after value when the date or time is changed in the UltraDateTimeEditor control. As always I’m sure there are other ways to accomplish this. Hope this helps.

Here is the event handler.

        private void documentDateUltraCalendarCombo_TextChanged(object sender, EventArgs e)
        {
            if (sender != null)
            {
                MessageBox.Show("After:" + ((Infragistics.Win.UltraWinEditors.UltraDateTimeEditor)sender).Editor.Value.ToString());
            }
            MessageBox.Show("Before:" + documentDateUltraCalendarCombo.DateTimeControl.Value.ToString());
        }

Here is the event handler being assigned to the control’s TextChanged event.

            documentDateUltraCalendarCombo.DateTimeControl.TextChanged += documentDateUltraCalendarCombo_TextChanged;
Advertisements

Visual Studio 2010 calling SQL 2005 Reporting Services

I have SQL 2005 reporting services that host a couple of reports. In the past I’ve been able to access these report via a web page built in Visual Studio 2005. However, a recently created web application in Visual Studio 2010 has caused me some grief. I ran into issues with reports not being displayed, to JavaScript errors, etc.

Using the ReportViewer control in VS2010 allows running of remote SQL reports from report server 2008 and above http://msdn.microsoft.com/en-us/library/bb885185.aspx. This is where I ran into my first issue since my remote report was in SQL 2005 Reporting Services. Anyway, here is how I went about executing a SQL 2005 Report from a web page within Visual Studio 2010. Hope this helps.

1. From VS2010, create a new ASP.NET web application. By default this will target .NET Framework 4.

2. We will work with the "Default.aspx" page here. Open the page’s source code and add the following code just under the "page" directive.

Code Snippet
  1. <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
  2.     Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

3. Add the following code where you want the report displayed. I have a report named "MyReport" under a folder "Reports".

Code Snippet
  1. <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
  2.     Height="400px" ProcessingMode="Remote" Width="400px">
  3.     <ServerReport ReportPath="/Reports/MyReport" ReportServerUrl="http://myserver/ReportServer$SQL2005&quot; />
  4. </rsweb:ReportViewer>

4. In the project references, add the reference to "Microsoft.ReportViewer.WebForms 8.0.0.0 v2.0.5.727".

5. In Web.Config, add the following within the "System.Web" section.

Code Snippet
  1. <httpHandlers>
  2.   <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  3. </httpHandlers>

6. Run your web page in the browser and hope you see the report as I do.

Good luck!

Embarcadero ER/Studio – Updating the Physical model with database changes

If you’ve reverse-engineered an existing database and then made updates to the physical database here is how you can refresh the model.

  1. Select the Main Model under the Physical option on the Data Model pane.
  2. Right-click on the model diagram and choose the Compare and Merge utility option.
  3. Choose the Compare against a live database option.
  4. Choose the following prompts according to your needs. At the end you will see the differences between the physical model and the database and have the options to import or ignore the objects.

Single row, multiple columns to variables in SSIS

The SQL Execute task in SSIS allows you to execute a SQL that would return a single row with multiple columns and then map these columns to variables within the package. To do this,

  1. In the General section set the Resultset property to “Single row”.
  2. Set the SQL statement.
  3. In the Result Set section, set the Result Name to 0 – n and the corresponding variables to be mapped. Ensure that the column order is right. I believe you can also use the column name but haven’t tried that.

Execute remote batch file from SQL job task

So I was asked if I could execute a batch file after an ETL was complete. The batch file to be executed resided on a remote server. The process currently involves a scheduled SQL job that first executes a SSIS package and then a stored procedure. Here are the steps I performed to be able to achieve this.

  1. On the remote server perform the steps as detailed in this Microsoft article Setting up Remote WSH.
  2. Create a BatToCall.bat batch file that will reside on the remote server. This is the batch file that we are going to execute remotely.
  3. Create a ExecuteRemotely.wsf script file. This script file will reside locally where the task is being executed but when called will perform the stated operations remotely.
  4. Create a Caller.wsf script file that will be called from the SQL job. This script file in turn will call the ExecuteRemotely.wsf script file.
  5. Create a SQL job with a step of type “Operating system (CmdExec)”. In the command, type “CScript Caller.wsf”. (The CScript command can be run from the command-line as well.)
  6. Execute the SQL job with appropriate permissions in place should execute the remote batch file.

Here is sample code for the above mentioned files.

BatToCall.bat


echo | time > C:\ExecutedHere.txt

Caller.wsf

<package>
<job>
<script language="VBScript">
set oController = CreateObject("WSHController")
set oProcess = oController.CreateScript("C:\ExecuteRemotely.wsf", "\\RemoteServerName")
WScript.ConnectObject oProcess, "remote_"

oProcess.Execute
While oProcess.Status <> 2
   WScript.Sleep 50
WEnd
WScript.Echo "Done"

Sub remote_Error
    Dim theError
    Set theError = oProcess.Error
    WScript.Echo "Error " & theError.Number & " - Line: " & theError.Line & ", Char: " & theError.Character & vbCrLf & "Description: " & theError.Description
    WScript.Quit -1
End Sub

</script>
</job>
</package>

ExecuteRemotely.wsf

<package>
<job>
<script language="VBScript">
Dim WShell
set WShell = CreateObject("WScript.Shell")
WShell.Run "C:\BatToCall.bat"
Set WShell = nothing
</script>
</job>
</package>

Inserting space between OneNote notes

When I needed space at the top of a OneNote page that already had a bunch of notes I used to go through the pain of moving each note around to create more space. However, today I found this cool menu option under the “Insert” menu option called “Extra Writing space”. Use that to insert or reduce space between your notes.

Choose the menu option and move your mouse over your page. You will see either a horizontal or a vertical line appear depending on the location of the mouse cursor over the page. Left-click the mouse button, hold and drag appropriately to add or reduce space on the page. If you perform this operation in the middle of a note I noticed it splits the note into two.