Wednesday, March 17, 2021

No creatable public component detected

 


Error :  "No creatable public component detected"


When trying to recompile a ActiveX.dll in VB6, I get the Message "No Creatable Public Component Detected There was no error in code .

Solution:

In the ActiveX DLL projects you need to have at least 1 class module with
the Instancing property set to MultiUse or GlobalMultiuse. Open up each
class module in the IDE and check the properties window 

Just change the instancing to Multiuse or GlobalMultiuse:


Add an XML Sitemap to your Blogger Blog

 The XML Sitemap file is like a directory of all web pages that exist on your website or blog. Google, Bing and other search engines can use these sitemap files to discover pages on your site that their search bots may have otherwise missed during regular crawling.

The Problem with Blogger Sitemap Files

A complete XML sitemap file should mention all pages of a site but that’s not the case if your blog is hosted on the Blogger or blogspot platform.

Google accepts sitemaps in XML, RSS, or Atom formats. They recommend use both XML sitemaps and RSS/Atom feeds for optimal crawling.

The default atom RSS feed of any Blogger blog will have only the most recent blog posts – see example. That’s a limitation because some of your older blog pages, that are missing in the default XML sitemap file, may never get indexed in search engines. There’s however a simple solution to fix this problem.

Generate XML Sitemap for your Blogger Blog

This section is valid for both regular Blogger blogs (that have a blogspot.com address) and also the self-hosted Blogger blogs that use a custom domain (like postsecret.com).

Here’s what you need to do to expose your blog’s complete site structure to search engines with the help of an XML sitemap.

  1. Open the Sitemap Generator and type the full address of your Blogger blog.
  2. Click the Generate Sitemap button and this tool will instantly create the XML file with your sitemap. Copy the entire text to your clipboard.
  3. Next, go to your Blogger.com dashboard, navigate to Settings –> Search Preferences, enable Custom robots.txt option (available in the Crawling and Indexing section). Paste the XML sitemap here and save your changes. And we are done. Search engines will automatically discover your XML sitemap files via the robots.txt file and you don’t have to ping them manually.


Internally, the XML sitemap generator counts all the blog posts that are available in your Blogger blog. It then splits the posts in batches of 500 posts each and generates multiple XML feed for each batch. Thus search engines will be able to discover every single post on your blog since it would be part of one of these XML sitemaps.

Tuesday, March 16, 2021

Install and uninstall Windows services using InstallUtil.exe utility

 Install using InstallUtil.exe utility
  1. From the Start menu, select the Visual Studio <version> directory, then select Developer Command Prompt for VS <version>.

    The Developer Command Prompt for Visual Studio appears.

  2. Access the directory where your project's compiled executable file is located.

  3. Run InstallUtil.exe from the command prompt with your project's executable as a parameter:

         installutil <yourproject>.exe

 you’re using the Developer Command Prompt for Visual Studio, InstallUtil.exe should be on the system path. Otherwise, you can add it to the path, or use the fully qualified path to invoke it. This tool is installed with the .NET Framework in %WINDIR%\Microsoft.NET\Framework[64]\<framework_version>.

For example:

  • For the 32-bit version of the .NET Framework 4 or 4.5 and later, if your Windows installation directory is C:\Windows, the default path is C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe.
  • For the 64-bit version of the .NET Framework 4 or 4.5 and later, the default path is C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.

Uninstall using InstallUtil.exe utility

1.    From the Start menu, select the Visual Studio <version> directory, then select Developer Command Prompt for VS <version>.

The Developer Command Prompt for Visual Studio appears.

2.    Run InstallUtil.exe from the command prompt with your project's output as a parameter:

installutil /u <yourproject>.exe

3.    After the executable for a service is deleted, the service might still be present in the registry. If that's the case, use the command sc delete to remove the entry for the service from the registry.

 


Monday, March 15, 2021

Refresh the list of remote branches in Visual Studio Team Explorer Visual Studio 2017/2015/2019

 Visual Studio 2019


By default the Visual Studio Team Explorer does not refresh the remote branches when you fetch updates from the server. The fix for this is pretty easy, you need to set "Prune remote branches during fetch" to true in the "Git Settings". You can do this in the global settings or per repository.

  • Go to Team Explorer settings
  • Select either "Global Settings" or "Repository Settings"
  • Set "Prune remote branches during fetch" to true

Prune remote branches during fetch And your done, now the remote branches will be updated every time you fetch or pull.

Visual Studio 2015/2017 - Refresh remotes/origin

  • Right-click on your local repo and select Open Command Prompt
  • run git fetch --prune   

Calculate Date and Time Difference Between Two Dates C#

A very common requirement is to display the Date and Time difference between two dates. 
Let us see how to do it:

C#

public class Program
{
public static void Main()
{
   DateTime date1 = 
   System.Convert.ToDateTime("2009-1-01 11:08:22");

   DateTime date2 = 
   System.Convert.ToDateTime("2009-1-02");

   TimeSpan ts = new TimeSpan();

   ts = date2.Subtract(date1);

   Console.WriteLine(ts.Days + " Days "  + ts.Hours + " Hours " +   ts.Seconds + " Seconds ");        

}
}


Output:

 0 Days 12 Hours 38 Seconds 

Copy paste not working issue in Remote Desktop (RDP)



Problem/Issue

The clipboard sharing is handled using a small application running on the remote machine, called "RDPCLIP.EXE". If this application fails to do the job, your clipboard sharing will stop working and you will not be able to copy paste text, data or files from local computer to remote server using remote desktop connection.

Solution:

Here is how you can solve this problem:

1. Login to remote computer using Remote Desktop (RDP)
2. Open Task Manager in the remote machine
3. Click the "Process" tab
4. Locate a program called "rdpclip.exe"
5. Right click and select "End process" to kill this program
6. Click on "File" menu in the task manager and select "New Task (Run)"
7. Type rdpclip.exe and press the button to start the process.




By killing existing instance of the rdpclip.exe and restarting the program, you can get your copy paste work again in your remote desktop.


Trim last character from a string or each word C#


Input:
I have a string say 
"Hello! world!" 
I want to do a trim or a remove to take out the ! off world but not off Hello.
Solution:
"Hello! world!".TrimEnd('!');


PHP: short_open_tag Not working in php 5.3.1


<? ?> tags not working in php 5.3.1

Issue/problem

I just installed php 5.3.1 in server and now my old work which I used to write with <? ?>  tags is not working at all..
Solution:

WAMP Server 
  1. Click on the wampserver tray icon.
  2. Go to PHP. Then PHP Settings
  3. Click short open tag. (When it's on it will have a checkmark next to it.)
XAMPP

If you are using xampp in windows then please do following

  1. Open XAMPP control panel.
  2. Click on CONFIG button.
  3. Go to PHP (php.ini) option.

Find short_open_tag using ctrl+f utility

You will found ;short_open_tag

kindly remove the semicolon (;) from line.

and keep it as short_open_tag = on

Finally, restart your Apache server


If you use wamp or xamp or iis 7 -> php manger , it's really easy to activate them. Just click on icon->php server->setting->allow short tag open

Remember to set UpdatePanel's UpdateMode to Conditional


UpdateMode property of the UpdatePanel


Since the cool thing about the ASP.NET Ajax UpdatePanel is that its contents are updated asynchronously when an event that would normally generate a postback is raised inside, one would think that this is its default behavior.
But it's not: the UpdateMode property of the UpdatePanel has 2 possible values:
  • Always
  • Conditional
and the default value is Always.

  • When set to Always, the UpdatePanel is updated on every postback raised from anywhere in the page, so from controls inside the panel, inside other panels or just on the page.
  • When set to Conditional, the UpdatePanel will be updated only on postback originated by controls inside the panel or from the triggers specified.
So, if you have multiple update panels and you don't want to update all of them to be updated every time, you have to set the UpdateMode to Conditional:

<asp:UpdatePanel ID="UpdatePanel1" 
                  UpdateMode="Conditional"
                  runat="server">

GROUPING SETS Clause in SQL Server


Introduction

We all know the use of a "group by" statement. Normally a GROUP BY statement is used in conjunction with aggregate functions (like sum, count, avg etc.) to group the result-set by one or more columns. In a sort, whenever data is to be summarized, the developer uses a Group By clause. The GROUP BY clause is also used to get DISTINCT rows from any result set.
GROUPING SET is introduced in SQL Server 2008. GROUPING SET is able to generate a result set that can be generated by a UNION ALL of multiple simple GROUP BY clauses. It is capable of generating a result set that is equivalent to the result set generated by ROLL UP or CUBE operations.

GROUPING SETS Equivalents

Specifying GROUPING SETS as the GROUP BY list is equivalent to a UNION ALL of queries, each with one of the grouping sets as its GROUP BY list. We can also use GROUPING SETS in replacement of ROLLUP and CUBE.



Example

In this example, an Employee Master table is created and some dummy values are inserted:


CREATE
 TABLE #EmployeeMaster
(

      EmployeeCode varchar(10),
      EmployeeName varchar(25), 
      DepartmentCode varchar(10),
      LocationCode varchar(10),
      salary int

)
INSERT into #EmployeeMaster(EmployeeCode, EmployeeName, DepartmentCode, LocationCode ,salary)
VALUES

(
'E0001', 'Jignesh', 'IT','GNR', 2000),
(
'E0002', 'Tejas', 'IT','GNR',  5000),
(
'E0003', 'Rakesh', 'QA','BVN', 4000),
(
'E0004', 'Bhavin', 'QA','BVN', 2000),
(
'E0005', 'Sandip', 'HR','ABD', 3000),
(
'E0005', 'Tarun', 'HR','ABD', 5000)


Now I want some summarized data, like total cost by Employee, total cost by Department, total cost by location and total cost for all employees with all locations in a single result set. 
Before SQL Server 2008, to do this we must write a different query and UNION these queries (this is the same as the following query).

SELECT EmployeeCode, DepartmentCode, LocationCode, SUM(salary) TotalCost
FROM
 #EmployeeMaster
Group
 BY EmployeeCode, DepartmentCode, LocationCode
UNION
SELECT
 NULL AS EmployeeCode, DepartmentCode, NULL AS LocationCode, SUM(salary) TotalCost
FROM
 #EmployeeMaster
Group
 BY DepartmentCode
UNION
SELECT
 NULL AS EmployeeCode, NULL AS DepartmentCode, LocationCode, SUM(salary) TotalCost
FROM
 #EmployeeMaster
Group
 BY LocationCode
UNION
SELECT
 NULL AS EmployeeCode, NULL AS DepartmentCode, NULL AS LocationCode, SUM(salary) TotalCost
FROM
 #EmployeeMaster 
With SQL Server 2008:
SELECT EmployeeCode, DepartmentCode, LocationCode, SUM(salary) TotalCost
from
 #EmployeeMaster
Group
 BY
  GROUPING SETS

  
(
    
(EmployeeCode, DepartmentCode, LocationCode)
   ,(DepartmentCode)
   ,(LocationCode)
   ,()       
  )
 




Conclusion

Using GROUPING SETS, we can write multiple "Group By" clauses within a single query and get a single result set. Also it can be used as equivalent to as well as with ROLLUP and CUBE.

Friday, March 12, 2021

How to get first record out of each group from the result retrieved by using group by command


Suppose if Input is:
ID GROUP ID  QTY
1 1 100
2 1 200
3 1 300
4 2 98
5 2 198
6 3 175
7 3 275
8 3 375
9 4 215
Output should be
ID GROUP ID  QTY
1 1 100
4 2 98
6 3 175
9 4 215

 Solution:
 Get first record out of each group from the result:
declare @T table (ID int, GroupID int, Qty int)
insert into @T values
(1, 1, 100),
(2, 1, 200),
(3, 1, 300),
(4, 2, 98),
(5, 2, 198),
(6, 3, 175),
(7, 3, 275),
(8, 3, 375),
(9, 4, 215)

;with cte as
(
  select
    ID,
    GroupID,
    Qty,
    rank() over(partition by GroupID order by ID) as rn
  from @T
)  
select ID, GroupID, Qty
from cte
where rn = 1