Saturday, 30 December 2017

How to update npm [Node Package Manager]?

Open your command prompt,

First, lets check we have installed npm or not. type npm -v on your command prompt.

Check version of npm : npm -v



Now we got the installation version. Here my version is 5.6.0

Lets update npm by using this command,


npm i -g npm


Update npm : npm i -g npm

Saturday, 26 March 2016

Open form with Form Name in winform appliaction


When we have only the form name and need to show / open the particular form after we clicked on a button or a menu strip is dynamically created, we need some dynamic code to handle the situation.

Here is the solution to open the particular form dynamically,



Code:
string  _formName ="MyForm";
System.ReflectionAssembly _asm = System.Reflection.Assembly.GetExecutingAssembly();
var _frm = (Form)(_asm.CreateInstance(this.GetType().Namespace+"."+ _formName));
_frm.Show();



Or

Code:
 var _frm = (Form)Activator.CreateInstance(Type.GetType(this.GetType().Namespace+"."+  _formName));
_frm.Show();

Thanks,

Friday, 24 July 2015

[Solved] ORA-20003: ORU-10036: object is invalid and cannot be described ORA-06512: at "SYS.DBMS_DESCRIBE",







Hi, I got this error because of my previous post...  ;)

ORA-20003: ORU-10036: object is invalid and cannot be described ORA-06512: at "SYS.DBMS_DESCRIBE",

But finally I got a solution, .. that here I post..


This will happens when we made operations such as upgrades, patches and DDL changes are  invalidate schema objects, so we need to recompile these invalidate object for further processing.

We can solve it manually like this,


ALTER PACKAGE my_package COMPILE;

ALTER PACKAGE my_package COMPILE BODY;

ALTER PROCEDURE my_procedure COMPILE;

ALTER FUNCTION my_function COMPILE;

ALTER TRIGGER my_trigger COMPILE;

ALTER VIEW my_view COMPILE; 


Also there is a another method, I used it because ....... ;)

 Login in SQL plus as SYSDBA and execute utlrp.sql file.








Don't worry copy this ....      @?\rdbms\admin\utlrp.sql       :D

How to change not null column to null ?












 Here is the code ...
.


  ALTER TABLE DRIVER_MASTER
  MODIFY (DRIVER_LICENCE_No NULL); 


Here I change my DRIVER_LICENCE_No  field to  nullable.

Tuesday, 21 July 2015

Get serial number with select query





Yes,  We can select serial number / record number with our selected result from sql server , Its very easy , here is the code

SELECT ROW_NUMBER() OVER (ORDER BY EmployeeName) AS   SlNo, 
              Department ,
              EmployeeCode,
              EmployeeName           
FROM    EmployeeMaster
WHERE  Active = 1
 

Here I used  ROW_NUMBER() function to get  serial number with the ascending order of employee name.  There is an option to get result order against multiple fields like this

ROW_NUMBER() OVER (ORDER BY Department ,EmployeeName)  AS  SlNo 


Sunday, 19 July 2015

How to know sql server version and edition?


         







 We can easily identify the server version and edition by execute an SQL query in SQL server. Here is the code ...




SELECT Serverproperty('Edition')        AS Edition,
       Serverproperty('ProductVersion') AS ProductVersion 

Thursday, 16 April 2015

Bind combo box in C#.net with Dictionary.

 
Hi, here I am going to fill my combo box "cmbCategory" with dictionary "_dtcCategory". Its pretty simple


Here is the Code:
       Dictionary < int, string > _dtcCategory = new Dictionary < int, string > ();
       _dtcCategory.Add(0, "       -Select-      ");
       _dtcCategory.Add(1, "Students");
       _dtcCategory.Add(2, "Employees");

       cmbCategory.DataSource = new BindingSource(_dtcCategory, null);
       cmbCategory.DisplayMember = "Value";
       cmbCategory.ValueMember = "Key";

Thursday, 12 March 2015

Rename column name in sql server











Hi,
   Sql server provide a procedure to do this function is SP_RENAME.  

And the code right here,


SP_RENAME 'Book.BookType','FK_BookTypeID','COLUMN';


Here : Book is my table name,having field  BookType. Here I have to rename the field to FK_BookTypeIDCOLUMN is the object -type I need to change.





Monday, 15 December 2014

Get last date of month in sql SQL server






here is the solution

SELECT Dateadd(dd, -Day(Getdate()), Dateadd(mm, 1, Getdate())) 

you will get the result like














Replace  Getdate() function with your date will give you the last date that you want.


SELECT Dateadd(dd,-Day('2015/02/16'), Dateadd(mm, 1, '2015/02/16')) 


Result :

















Thank you. :)

Wednesday, 3 December 2014

Get insert query from selected data in toad?





Hi,
    Now am here to tell about insert script generation from toad software. here is the steps ...


Step 1 : Write your query in editor window.





Step 2 : Click select all button in script output.














Step 3 : Right click on grid header and click Export Dataset.






















Step 4 : Select export format as Insert statement. Add output path with name. Also provide table name








































Step 5 : Click Ok button . You can get your insert statement from the path you specified.


Thank you. happy coding  :)

Monday, 1 December 2014

How to update table with data from another table in Oracle?





Here is a sample code ...

UPDATE customers
SET    c_details = (SELECT contract_date
                    FROM   suppliers
                    WHERE  suppliers.supplier_name = customers.customer_name)
WHERE  customer_id < 1000; 


here customers,suppliers  are my table 


here I am going to update c_details in customers table with  contract_date in 
suppliers table with the condition suppliers.supplier_name = customers.customer_name.   

 and customer_id is less then 1000 .



Monday, 24 November 2014

How to get group wise data from Datatable in C#?


Hi, If you face the problem  till now, don't worry I have a solution.,

if you have the data like this ....

id|empName |designation
-----------------------------------
1 |john    |manager 

2 |manu    |ast.manager 
3 |mathew  |accountant 
4 |sree    |ast.manager

And need to group this by designation?  The given LINQ C# code will help you to solve this



var EmData = from row in dtEmpData.AsEnumerable()
group row by new
{
des = row.Field<string>("designation")

} into g
select new
{
designation = g.Key.des,
ColumnValues = g
};


:) By using two for each statements will help you guys to traverse through these record

foreach (var k in EmData)
{
      // you can access designation by using   k. designation


     foreach (var columnValue in k.ColumnValues )
    {
      // access group by result [Employee details] through this expression   columnValue["id"]
     } 

}


:) Thank you.

Sunday, 23 November 2014

How to get details of all newly restored databases from SQL server?


Here is the code to get all restored databases in SQL server.





WITH lastrestores
     AS (SELECT DatabaseName = [d].[name],
                [d].[create_date],
                [d].[compatibility_level],
                [d].[collation_name],
                r.*,
                RowNum = Row_number()
                           OVER (
                             partition BY d.NAME
                             ORDER BY r.[restore_date] DESC)
         FROM   master.sys.databases d
                LEFT OUTER JOIN msdb.dbo.[restorehistory] r
                             ON r.[destination_database_name] = d.NAME)
SELECT *
FROM   [lastrestores]
WHERE  [rownum] = 1 



Just paste this code to query window and execute,. Its results the restored database list.
  

:)