Home Contact

Natasa Gavrilovic

my Explorations in Coding

News

Archives

Post Categories

More about me...

Syndication:

SSRS optional parameters settings

Recently I had to create couple SQL Server Reports (SSRS) with optional parameters built in. It took me a while to refresh memory how this can be done. It was very simple to create reports and processes behind, but connecting these two were are little bit challenging – stored procedure was tested and worked fine, but when the report was passing optional parameters it didn’t returned expected results. After tweaking SQL stored procedures and reports parameter options, the following approach turn to be the winning one.

1) Defining report parameters:

From Menu bar select ‘View’ and ‘Report Data’

Newly open window should have ‘Parameters’ folder display

Right click on this folder and select ‘Add new parameter...’

 

optionalParams_01

 

 

 

 

 

 

 

 

 



optionalParams_02

 

 

 

 



Default values need to be added from a query

optionalParams_03

 

 

 

 

 

 

 

 



A query values need to include ‘’ (empty string) – as highlighted

optionalParams_04

 

 

 

 

 

 

 

 


 

2) SQL stored procedure should have CASE statements inside WHERE

and it was the only way that a report was getting correct results back.

optionalParams_05

 

 

 

 





Reading txt file - code sample

Recently I worked with data temporary stored in a txt file.  As the files were not present all the time at the location, the code should first check if a required file exists.
Two different ways were used based on other requirements not included here. 

 
1. If more than one file is present, search for the most recent one (in this case, the one that was created today.)

docpath = ConfigurationManager.AppSettings("FileLocation")
        filename = "testFile.txt"
        filescount = System.IO.Directory.GetFiles(docpath, filename)
        If filescount.Length > 0 Then
            For i = 0 To filescount.Length - 1
                ExistingFile = System.IO.File.GetLastWriteTime(filescount(i))
                If ExistingFile.Substring(0, 10) = Today Then
                    '
                    '
                End If
            Next
        End If

2. If a specific file exists, read the file, and add values to a newly crated list of objects.

dim docpath as String = string.empty
  dim filename as String = string.Empty
  docpath = ConfigurationManager.AppSettings("FileLocation")
  filename = "testFile.txt"
  Dim Exists As Boolean = My.Computer.FileSystem.FileExists(docpath & filename)

            If Exists = True Then
                Dim FileText As String = My.Computer.FileSystem.ReadAllText(docpath & filename)
                Dim textLine As String()
                textLine = FileText.Split(Trim(CChar(Environment.NewLine)))
                If textLine.Length > 1 Then
                            For i = 0 To textLine.GetUpperBound(0)
                                If textLine(i).Trim().Length > 0 Then
                                    frmTest.lstItems.Items.Add(textLine(i).Trim().ToUpper())
                                End If
                            Next i
                        End If
                    End If
                End If
            End If



MS HTML5 WebCamp: few words on...

Recently I attended Microsoft HTML5 WebCamp where I had a chance to get insights on all new features HTML5 has to offer. Couple things to mention:
 
- Canvas - a new HTMl5 feature that uses JavaScript to draw bitmap graphics on a web page. Simple approach (less JS coding) makes this interesting: empty space is treated as a painter canvas and a painter brush is replaced with JavaScript.
 
- SVG (Scalable Vector Graphics) is another graphic tool widely publicized. It is not new, it has been around for a decade, but it is getting a new shot with HTML5. One of the main reasons is its scalability as all objects created as SVG are optimized to be viewed in different resolutions (PC screen, mobile device etc).  Tools like Adobe Photoshop, Inkscape, Xara X can produce professional svg graphics.
 
- We couldn’t left Internet Explorer 9 out – we were remind ‘What developers think of Internet Explorer' before discussion start rolling on GPU (Graphics Processing Unit) acceleration. The featured presentation put Internet Explorer 9 on the first place before Mozilla Firefox 6, Google Chrome and Opera by the time it took to render a page. The example below, HTML5 Blizzard, was very convincing that GPU enabled browser renders much faster and provides better graphic experience.
 
IE9 GPU can be enabled by unchecking ‘Use software rendering instead of GPU rendering’ in Internet Options.

N.

 

 



Wow6432Node

If you upgraded your system to Windows 64 bit one and try to run 32 bit web application registry key entries are not going to be located at the same place.
 
Apparently, 64 bit based version of Windows has a new registry branch for 32 bit programs. It is located in HKEY_LOCAL_MACHINE\Software registry folder named ‘Wow6432Node’. New program installations are monitored by system and registry entry are placed in proper folders based on is 32 or 64 bit program.