Monday, April 27, 2020

python -m pip install Scrapy - error: command 'cl.exe' failed: No such file or directory

While Installing Scrapy library in windows in case if you receive "Command 'cl.exe' failed" error means the system doesn't have Microsoft C Compiler or Environment path not set properly.

To Fix this error try installing Desktop Development with C++ from Visual Studio Installer.  After installing it try running this command in windows Command prompt python -m pip install Scrapy



Sunday, April 26, 2020

HowTo update PIP

Sometime we need to upgrade PIP in our machine. to upgrade use this command python -m pip install --upgrade pip in the windows command prompt.


pip install matplotlib - SyntaxError: invalid syntax


When we are trying to install mapplotlib using PiP command into the python interactive prompt then it will throw invalid syntax error. To Over come this issue try running this command windows command prompt "python -m pip install matplotlib" Note: before running this command install python in the machine.


Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pip install matplotlib
  File "", line 1
    pip install matplotlib
        ^
SyntaxError: invalid syntax

Friday, May 13, 2016

SSRS 2005 - How To Format Globals!ExecutionTime To "MM/dd/yyyy"


To format the build-in global in SSRS 2005 you have to you  FORMAT functions which will take two parameters (Expression & Style)


Example

         = FORMAT(Globals!ExecutionTime, "MM/dd/yyyy") 

Friday, August 14, 2015

Select Query - Case Statement In Order by - Msg 241 - Conversion failed when converting datetime from character string Error

        Today when i was working on store procedure which i need to use case statement in Order by in the select clause i have came across the following issue,

Msg 241, Level 16, State 1, Line 16
Conversion failed when converting datetime from character string.


        After a spending some time I found the root cause of this issue, the golden rule we have to use the same type in all the branches of case/when.

Sample Code

Execute the below sample script to recreate that issue,

DECLARE @tmpTBL table
(
    ID INT IDENTITY(1,1),
    SampleDT datetime
)

INSERT INTO @tmpTBL VALUES('2015-08-01');
INSERT INTO @tmpTBL VALUES('2015-08-02');
INSERT INTO @tmpTBL VALUES('2015-08-03');
INSERT INTO @tmpTBL VALUES('2015-08-04');

Declare @SordDirection CHAR(1); SET @SordDirection = 'D';
Declare @OrderBy VARCHAR(10);SET @OrderBy = 'SampleDT';

SELECT * FROM @tmpTBL
ORDER BY
        CASE WHEN @SordDirection ='D' THEN 'A'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT
        END
        END ASC,
        CASE WHEN @SordDirection='A' THEN 'D'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT
        END
        END DESC












 

Replace the  CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT with the following line 
CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))

After replacing if you execute the script, you can see the results without any issues,





 







 
Complete Script

DECLARE @tmpTBL table
(
    ID INT IDENTITY(1,1),
    SampleDT datetime
)
INSERT INTO @tmpTBL VALUES('2015-08-01');
INSERT INTO @tmpTBL VALUES('2015-08-02');
INSERT INTO @tmpTBL VALUES('2015-08-03');
INSERT INTO @tmpTBL VALUES('2015-08-04');

Declare @SordDirection CHAR(1); SET @SordDirection = 'D';
Declare @OrderBy VARCHAR(10);SET @OrderBy = 'SampleDT';

        SELECT * FROM @tmpTBL
ORDER BY
        CASE WHEN @SordDirection ='D' THEN 'A'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))
        END
        END ASC,
        CASE WHEN @SordDirection='A' THEN 'D'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))
        END
        END DESC

Saturday, May 16, 2015

Sql Server order by month name


Following Script will order the result in actual calendar month order.

SELECT *  FROM [dbo].[tablename]
ORDER BY DATEPART(mm,CAST([DateFieldColumnName] + ' 1900' AS DATETIME)) ASC

Thursday, October 23, 2014

How To retain aspajax:CalendarExtender selected value after postback




Try This below snippet to retain the CalendarExtender selected value after postback


if(isPostback)
{
           YourCalendarExtender.SelectedDate =
                    DateTime.ParseExact(YourTextBox.Text, YourCalendarExtender.Format, null);
}

Thursday, September 25, 2014

Command Prompt How to list all files in a folder as well as sub-folders in windows


Step 1 : Goto required folder in Command prompt.

Step 2: Type the following command    dir /b /s 

              /b - User bare format
              /s - Lists the files in the directory that you are in and all sub directories after that directory

              Step 2 will list all the files reside in the parent folder and it's sub folder.

Step 3: To get the specific file give the appropriate file extension. for example if we need sql file to be listed, give the following command dir /b /s *.sql | sort

Wednesday, April 9, 2014

ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary — Speed, memory, and when to use each?


Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion and retriv. speed.

ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET

List - one of my favs - can be used with generics, so you can have a strongly typed array, e.g. List. Other than that, acts very much like ArrayList.

Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs.

Dictionary - same as above only strongly typed via generics, such as Dictionary

but note Hashtable has less performance than Dictionary because of Boxing and Unboxing.

SortedList - a sorted generic list. Slowed on insertion since it has to figure out where to put things. Can enum., probably the same on retrieval since it doesn't have to resort, but deletion will be slower than a plain old list.

I tend to use List and Dictionary all the time - once you start using them strongly typed with generics, its really hard to go back to the standard non-generic ones.

There are lots of other data structures too - there's KeyValuePair which you can use to do some interesting things, there's a SortedDictionary which can be useful as well.




Courtesy - Stackoverflow


Wednesday, March 26, 2014

Access modifiers

public
The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private
The type or member can only be accessed by code in the same class or struct.
protected
The type or member can only be accessed by code in the same class or struct, or in a derived class.
internal
The type or member can be accessed by any code in the same assembly, but not from another assembly.
protected internal
The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly.

Friday, February 28, 2014

Entity framework in WCF Service - Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool.



Incase if you getting the "Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool." while using the Entity framework WCF service required MSDTC follow the below steps,
 

To find that,
1. go to start -> run -> type "c:\Windows\System32\comexp.msc" or comexp.msc
2. Click Component Services
3. Click Computers. Under this, click "My Computer"
4. Once you open "My Computer" you will see 4 folders.
5. Click on Distributed Transaction Coordinator. Underneath this, you will see "Local DTC'
6. Right click "Local DTC" and go to properties.
7. Select Security Tab.
8. Check mark "Network DTC Access" checkbox
9. Finally check mark "Allow Inbound" and "Allow Outbound" checkboxes.
10. Click Apply, Ok.
11. A message will pop up about restarting the service.
12. Click ok and That's all.

Saturday, May 14, 2011

Forgot SQL Server Admin Password

exec sp_password @new='NewPassword', @loginame='sa'
go
alter login sa enable
go

Saturday, August 7, 2010

Bend Replacement for Traditional notepad ?

Notepad is the light-weight text editor for Windows OS for a long time with simple UI and limited functionalities. I had a chance to try bend for few minutes and I am convinced with its functionalities.

Bend have all the functionalities available in the notepad, and also having tab interface, better find and replace, Zoom Ctrl + Mouse Wheel, Syntax highlighting etc.

Its Prerequisites,

Note :Apparently Bend works on Vista and XP SP3 as well. As long as .net 4.0 works

Courtesy:Codeplex

Monday, February 1, 2010

How To Zip The Folder using VB script

Option Explicit

Const FOF_SIMPLEPROGRESS = 256
Dim MySource, MyTarget, MyHex, MyBinary, i
Dim oShell, oCTF
Dim oFileSys
dim winShell
Const cstrApp = "Zip It"
MySource = InputBox("Enter path to folder to zip (Ex:D:\xyzfolder)", cstrApp ) 'Example :"D:\test\"
MyTarget = InputBox("Enter path and name of Zip file (Ex:D:\xyz.zip)", cstrApp)'"D:\smp.zip"

MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0)

For i = 0 To UBound(MyHex)
MyBinary = MyBinary & Chr(MyHex(i))
Next

Set oShell = CreateObject("WScript.Shell")
Set oFileSys = CreateObject("Scripting.FileSystemObject")

'Create the basis of a zip file.
Set oCTF = oFileSys.CreateTextFile(MyTarget, True)
oCTF.Write MyBinary
oCTF.Close
Set oCTF = Nothing

'Add File to zip
set winShell = createObject("shell.application")
winShell.namespace(MyTarget).CopyHere MySource

wScript.Sleep(5000)

'Follow these steps only if you're receiving the 800A01AD error for Wscript.Shell component. For any other ActiveX object, the following steps does not apply:
'Click Start, Run and type:
' * regsvr32 wshom.ocx
' * regsvr32 scrrun.dll




Friday, January 1, 2010

Wishing you all a very joyful, peaceful and happy New Year.

Wishing you all a very joyful, peaceful and happy New Year.



Thursday, December 31, 2009

How To Add Border To Image Within DataGrid Column in Silverlight


<data:DataGridTemplateColumn Header="Image">
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" Width="101"  BorderThickness="1,1,1,1" Height="13" >
                                    <Image Width="25" Height="11" Source="http://localhost/SLR/images/pers_org.png" Stretch="UniformToFill" HorizontalAlignment="Left"  Canvas.Top="0" Canvas.Left="0" >
                                    </Image>
                                </Border>
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                    </data:DataGridTemplateColumn>

//Bind the Following code within datagrid LoadingRow Event

Border border = (Border)dgName.Columns[4].GetCellContent(e.Row);// value 4 is the Possible of the Cell in the datagrid
Image image = (Image)border.Child;
//RelMang tmpRm = (RelMang)e.Row.DataContext;
//image.Width = Convert.ToDouble(tmpRm.mx_Rel_Prcntg.ToString());
image.Width = Convert.ToDouble(20); // Dynamically Setting Width of the Image Which in Datagrid Cell

Thursday, December 24, 2009

Silverlight How To Pass Values Between Pages or Forms

In App.xaml.cs have declared some application level variables as follows,

private string valueToPass

public string valTo
{
    get
    {
        return valueToPass;
    }
    
    set
    {
        valueToPass = value;
    }
}

page1.xaml.cs

App ap = (App)Application.Current;
ap.valueToPass = "YourValue";


page2.xaml.cs

App ap = (App)Application.Current;
messageBox.show(ap.valueToPass);

How To wrap Text In silverlight DataGrid Column

Make your datagrid AutoGenerateColumns="False" , then do the following changes to wrap text in the datagrid coloumn

<data:DataGridTemplateColumn Header="Your Header" Width="150">
         <data:DataGridTemplateColumn.CellTemplate>
                 <DataTemplate>
                        <TextBlock TextWrapping="Wrap" Text="{Binding Your_Data_Display}" />
                 </DataTemplate>
        </data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

Wednesday, December 23, 2009

Silverlight The type or namespace name 'IValueConverter' could no


While Using Silverlight if you are getting the following Error "The type or namespace name 'IValueConverter' could not be found (are you missing a using directive or an assembly reference?)" Just Include namespace System.Windows.Data; in your code behind.

Silverlight The type or namespace name 'BitmapImage' could not be


While Using Silverlight if you are getting the following Error "The type or namespace name 'BitmapImage' could not be found (are you missing a using directive or an assembly

reference?)
" Just Include namespace System.Windows.Media.Imaging; in your application