How to Change the Connection String of Query in Infragistics Report at Run Time


In a previous article, we saw how we can create a report using Infragistics Reporting. If you have not read it so far, you can read it here. In that post you might have noticed that we are using the in-built SQL Data Source from the “Report Data Explorer” window. Now, normally we develop on our own development environment and when the code is deployed on a production environment, the database is completely different. So, we need to make sure that the report reads the query string from app.config or some other common place in the project that can be changed easily. In this post, we will how we can achieve the same. Let’s get started –

  • We open the same Visual Studio project that we created in our article here.infragistics-reporting-runtime-1
  • Infragistics provides a specific template named “Infragistics Report Database Connection Provider” which implements “IReportDbConnectionProvider” interface. We add a class to our project as show below and name it as “ReportDbConnectionProvider.cs”.infragistics-reporting-runtime-2
  • By default the template gives you the following code.infragistics-reporting-runtime-3
  • Now we need to identify the name of the Data Source used in our report. This can be found under the Data Sources section in the “Report Data Explorer” window as below –infragistics-reporting-runtime-4
  • Implement the following code in your “ReportDbConnectionProvider.cs” file.
            public DbConnection GetConnection(string name, IDictionary<string , ParameterValue> reportParameters)
                 switch (name)
                     case "sqlDatSource1":
                         return new SqlConnection(@"Data Source=NITESH\SQLEXPRESS;Initial Catalog=SampleDB;Integrated Security=True");
                         return null;
  • As you see above, I have added code in GetConnection() and returned an SqlConnection object with my custom connection string for the data source named – “sqlDataSource1” which is the Data Source used by our project.
  • Now, when you execute the project, your report will use the new connection string.

Hope you like this article. Keep learning and sharing!

How To Enable Task Manager in Windows 8.1


Windows Task Manager is used to view details about processes running on your computer. Today, I cam across an application that was disabling the Task Manager by itself. In this post, we will see how to enable Task manager in Windows 8.1 machine via Registry. If the Task manager is disabled, you may get the following message when trying to access Task Manager –


  • Open Run windows from Start Screen, type regedit and press Enter.
  • The Registry Editor window will open. In this window, navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\Current Version\Policies\System through the left hand navigation panel.
  • Once you’re there, on the right side in the work area you will notice a Key named “DisableTaskMgr”.
  • Open the Key by double clicking on it and enter the value as 0.
  • Press OK and close the Registry Editor.

You’re done!

Hope this little tip helps you. Keep learning and sharing.

How To Disable File Preview in Visual Studio 2012


In visual Studio 2012, Microsoft released a very handy feature of auto previewing a file as soon as you select the file in Solution Explorer. However, this feature may become annoying at some scenarios. In this post, we will see few ways of disabling the same.

Option 1:

Go to Tools > Options > Environment > Tabs and Windows and uncheck the “Solution explorer” under Preview tab.


Option 2:

Click the icon from within Solution Explorer that says ‘Preview Selected Items’.


Hope you like this. Keep learning and sharing.

How to Create a Simple Report in Windows Forms Using Infragistics Reporting


Infragistics provides a complete cool set of products in its reporting library. In this post we will see how we can create a very simple report using Infragistics set of controls. This post assumes that you have already installed Infragistics Reporting on your system. If not, you can download it from here. Let’s get started –

  • Open Visual Studio & create a new Windows project. I will name the project as IGReport1 (here IG stands for Infragistics)infragisitcs-reporting-1
  • I have added a Report folder in my project to store all reports under same location. Then we add a new Infragistics Report to the project using “Add New Item”.infragisitcs-reporting-2
  • Once the report is added, you will see all relevant libraries are automatically referenced by Infragistics in the project and the report would look something like below screenshot –infragisitcs-reporting-3
  • Now, we will configure a data source for the report to display the data. To do so, we will either click on the center of the report that says “Add a Report Data Source or use Reporting Controls from the Toolbox to start designing a report” or we can do so via “View menu > Report Data Explorer”. They both open the same window. We will be using the “Report Data Explorer” approach.
  • Click on the 1st icon as marked in Red above to add a new data source.infragisitcs-reporting-4
  • Choose your type of Data Source and Click Next. We will use SQL Data Source for now.infragisitcs-reporting-5
  • Define the connection to SQL using the “New Connection” button and click “Next”. You can also name the Connection String to whatever you want to.infragisitcs-reporting-6infragisitcs-reporting-7
  • Once the connection is configured, the wizard displays you a list of all tables/views that you can use to build a query for retrieving data for the report. You can either select a table or use “SQL Builder” to create a new query. Also, you can name your data source to your choice. Once you have created the query, click Next.infragisitcs-reporting-8
  • In the next screen, you can test your query results using the “Test Query” button. If you’re happy with the result set, click “Finish” else go back and modify the datainfragisitcs-reporting-9
  • After the data source has been configured, you would see the entire columns under “Report Data Explorer” as belowinfragisitcs-reporting-10
  • Time to put the fields on the report. Just drag the data source , here ‘SqlDataSource1’ to the Report Body section and you’re done.infragisitcs-reporting-11
  • You can also click on “Preview” button present at the bottom of the report designer to view the final report how it looks like. The one we created looks like below –infragisitcs-reporting-12
  • Our Report part is done. Now, let us show this report on the Windows form. To show an Infragistics report in Windows Forms project, we will need another control provided by Infragistics named as “UltraReportViewer”. Let us add the control to our main form and configure it to display the report.infragisitcs-reporting-13
  • Now, run the project and it will look something similar to the below one.infragisitcs-reporting-14

Hope you like this article. Keep learning and sharing!

How To Refer Next & Previous Controls on HTML Page Using jQuery


In this post, we will see how can we refer to previous and next controls present on an HTML page using jQuery.

jQuery provides 2 very useful functions .prev() and .next() with the help of which we can refer to the immediate previous/next sibling of a given control. This is to be noted that these functions limit to the current reference of a DOM element.

From the jQuery documentation –

.prev() gets the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector

.next() gets the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.

Let’s see it in action –

<div id="div1">
   <input type="text" id="d1t1" />
   <input type="text" id="d1t2" />
   <input type="text" id="d1t3" />
<div id="div2">
   <input type="text" id="d2t1" />
   <input type="text" id="d2t2" />
   <input type="text" id="d2t3" />

In the above example, you can traverse between text boxes with ID ‘d1t1′, ‘d1t2′ and ‘d1t3′ or ‘d2t1′, ‘d2t2′ and ‘d2t3′ using the .prev() and .next() functions. You will not be able to traverse between ‘d1t1′ and ‘d2t1′ using these functions because they are contained in different parent div blocks. However, you can traverse between ‘div1′ and ‘div2′ using .prev() and .next() functions because they are immediate siblings.

Considering the same example above, lets see the below jQuery snippet now –

<script type="text/javascript" src="//"></script>
<script type="text/javascript">
        $(function () {            
            $("#d1t2").focusout(function () {

In the above snippet, I have handled focusout() event for the textbox ID “d1t2″. We use the .prev() and .next() functions to get the value of text boxes with ID ‘d1t1′ and ‘d1t3′ respectively.

Hope this gives you a brief insight on how .prev() and .next() functions work. In case you have any questions, let me know.

Keep learning & sharing!

How To Clear Items of ASP.Net DropDownList Control Using jQuery


In this post, we will see how can we clear all items of a ASP.Net DropDownList control using jQuery.

To start with, we will define a ASP.Net DropDownList control on our .aspx page and a button with the help of which we will be clearing the items of the DropDownList control. We assign it a specific class using the CssClass property that we can refer to in jQuery.

<asp:dropdownlist ID="lstPlayers" CssClass="lst-clear" runat="server">
            <asp:listitem Text="Sachin" Value="Sachin"></asp:listitem>
            <asp:listitem Text="Sehwag" Value="Sehwag"></asp:listitem>
            <asp:listitem Text="Dravid" Value="Dravid"></asp:listitem>
            <asp:listitem Text="Yuvraj" Value="Yuvraj"></asp:listitem>
            <asp:listitem Text="MS Dhoni" Value="MS Dhoni"></asp:listitem>
<input type="button" id="btnClear" value="Clear Items" />

After our controls are defined, we bind the click event of the button to clear the items using the .empty() function as below –

<script type="text/javascript" src="//"></script>
<script type="text/javascript">
        $(function () {            
            $("#btnClear").click(function () {

Hope you like this. Keep learning and sharing!

Solution: The server response was: 5.7.0 Must issue a STARTTLS command first. i16sm1806350pag.18 – gsmtp


When sending emails via code using Gmail as mail server, we sometime get this error. This blog post explains the error and the solution to the same.

The error occurs when the code tries to authenticate Gmail server using the given credentials over non-SSL layer and does not encrypt the connection.

To resolve this, you need to set EnableSsl property of your SmtpClient class’s object to true as mentioned below –

  SmtpClient client = new SmtpClient("");
  client.EnableSsl = true;

Hope you like this. Keep learning and sharing! Cheers!