Showing posts with label HowTo. Show all posts
Showing posts with label HowTo. Show all posts

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

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


Saturday, May 14, 2011

Forgot SQL Server Admin Password

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

Sunday, September 13, 2009

How To Send Mail With Attachment In Asp.Net

have to Include The following Namespace,

using System.Net;
using System.Net.Mail; // For Mailing Purpose
using System.IO;  // To Check File existence in Server
using System.Text; // For Encoding.UTF8

         try
        {
            MailMessage objMailMsg = new MailMessage(txtFrom.Text.Trim(), txtTo.Text.Trim());
            Attachment MailAttachment;

            objMailMsg.BodyEncoding = Encoding.UTF8;
            if (txtCc.Text.Trim().Length > 0)
            {
                objMailMsg.CC.Add(txtCc.Text.Trim());
            }
            if (txtBcc.Text.Trim().Length > 0)
            {
                objMailMsg.Bcc.Add(txtBcc.Text.Trim());
            }
            objMailMsg.Subject = "Testing Mail";
            objMailMsg.Body = txtMessage.Text.Trim();
            if (fuMailAtt.HasFile)
            {
                if (!File.Exists(Server.MapPath(@"Attach\" + fuMailAtt.FileName)))
                {
                    fuMailAtt.SaveAs(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
                    MailAttachment = new Attachment(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
                    objMailMsg.Attachments.Add(MailAttachment);
                }
                else
                {
                    MailAttachment = new Attachment(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
                    objMailMsg.Attachments.Add(MailAttachment);
                }
            }
            objMailMsg.Priority = MailPriority.High;
            objMailMsg.IsBodyHtml = true;

            SmtpClient objSMTPClient = new SmtpClient("smtp.mail.yahoo.com", 587);
            objSMTPClient.Credentials = new NetworkCredential("YourYahooId", "Your Yahoo Password");
            objSMTPClient.Send(objMailMsg);
            Response.Write("Mail Send");
        }
        catch (Exception ex)
        {
            Response.Write("Mail Not Send " + ex.Message);
        }

Controls Name

From Address        txtFrom
To Address            txtTo
Cc Address           
txtCc
Bcc Address          txtBcc
FileUpload             fuMailAtt
Message                txtMessage
Send Button           btnSend

Download SourceCode


Friday, August 21, 2009

Silverlight : How To Bring Control To Front

Canvas.SetZIndex(Your_Element_Name,Value_To_Bring_It_To_Front);

Thursday, August 13, 2009

How To Create Dynamic TextBox With Event Handler

    protected void Page_Load(object sender, EventArgs e)
    {
        createTxt();
    }

    private void createTxt()
    {
       
        TextBox txt = new TextBox();
        txt.ID = "txt1";
        txt.AutoPostBack = true;
        txt.TextChanged += new EventHandler(txt_TextChanged);
        form1.Controls.Add(txt);       
    }

    void txt_TextChanged(object sender, EventArgs e)
    {
        TextBox txtBx = (TextBox)sender;
        Page.Title = txtBx.Text;
    }


Wednesday, August 12, 2009

JavaScript Error Handling

JavaScript Standard Error Instance Properties
constructor
    Specifies the function that created an instance's prototype.
message
    Error message.
name
    Error name.

<html>
    <head>
        <title>Error Handling</title>
        <script language='javascript'>
        window.onload = function()
        {
            try
            {
                var x = 1;
                var value = x / y;               
            }
            catch(err)
            {
                alert("constructor"+ ": " + err.constructor +'\r\n' + 'message'+ ": " + err.message + '\r\n' + 'name' + ": "+ err.name);
            }
            finally
            {
                alert("Finally block");
            }

        }
        </script>
    </head>
</html>


How To Detect Silverlight Installed In Client Machine

<html>
    <body>
        <script language="javascript">
        var browser = navigator.appName;
        var SLInstalled = false;
        if (browser == 'Microsoft Internet Explorer')
        {
            try
            {
                var slControl = new ActiveXObject('AgControl.AgControl');//IE
                SLInstalled = true;
            }
            catch (e)
            {
                SLInstalled = false;
            }
        }
        else
        {   
            try
            {
                if (navigator.plugins["Silverlight Plug-In"]) // Other Than IE
                {
                    SLInstalled = true;
                }
            }
            catch (e)
            {
                SLInstalled = false;
            }
        }
            if(SLInstalled == true)
            {
                    alert('Silverlight Installed');
            }
            else
            {
                  alert('Silverlight Not Installed');
             }
        </script>
    </body>
</html>


Tuesday, August 11, 2009

How To Reset DoubleAnimationUsingKeyFrames

YourDoubleAnimationUsingKeyFramesName.KeyFrames.Clear();

How To Triggers Event In Silverlight

// Inlcude These two namespaces for the Automation Process
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;


ButtonAutomationPeer buttonAutoPeer = new ButtonAutomationPeer(YourButtonName);
IInvokeProvider invokeProvider = buttonAutoPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProvider.Invoke();


Monday, August 10, 2009

How To Get Storyboard Current Status

Syntax
          StoryboardName.GetCurrentState

GetCurrentState Method enumeration values are
          Active    -  The current animation changes in direct relation to that of its parent.
          Filling    -  The animation continues and does not change in relation to that of its parent.
          Stopped  -  The animation is stopped.


How To Convert a string to TimeSpan

TimeSpan.Parse("00:00:00");

Monday, August 3, 2009

Silverlight Alert Box

System.Windows.Browser.HtmlPage.Window.Invoke("Alert", "Testing");

How To Hide Legend In PieChar Silverlight

<UserControl x:Class="Charting.Pagee"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">

        <charting:Chart Title="Legend Disabled">         

            <charting:Chart.LegendStyle>
                
                <Style TargetType="datavis:Legend">
                    
                    <Setter Property="Width" Value="0"/>
                    <Setter Property="Height" Value="0"/>
                    
                </Style>
                
            </charting:Chart.LegendStyle>
            
            <charting:Chart.Series>
                
                <charting:PieSeries  DependentValuePath="X" >                    
                    <charting:PieSeries.ItemsSource>
                        <PointCollection>
                            <Point X="1"/>
                            <Point X="2"/>
                            <Point X="3"/>
                            <Point X="4"/>
                        </PointCollection>
                    </charting:PieSeries.ItemsSource>
                </charting:PieSeries>
                
            </charting:Chart.Series>
            
        </charting:Chart>
    </Grid>
</UserControl>