Saturday, December 19, 2015

IIS is not shrink with your ASP.NET framework



Sometimes your IIS is not shrink with your ASP.NET framework. As a result your publish application’s browsing url will not work.
To resolve this go to your installed framework folder
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe


Friday, November 13, 2015

run sql script from command line




 sqlcmd -S ATIK-PC\SQLEXPRESS -d STUDENT_DEV -U sa -P sa123 -i c:\schema.sql -o c:\log.txt  


Friday, November 6, 2015

SQL split a comma separated string

SQL split a comma separated string


 DECLARE @valueList varchar(8000)  
 DECLARE @pos INT  
 DECLARE @len INT  
 DECLARE @value varchar(8000)  
 DECLARE @i INT=0  
 SET @valueList = ',Atik,Khabir,Shahed,Shain,Ashek,Noman'  
 set @pos = 0  
 set @len = 0  
 WHILE CHARINDEX(',', @valueList, @pos+1)>0  
 BEGIN  
   set @len = CHARINDEX(',', @valueList, @pos+1) - @pos  
   set @value = SUBSTRING(@valueList, @pos, @len)  
      set @i=@i+1   
   --SELECT @pos, @len, @value /*this is here for debugging*/  
     IF(@i=1) -- now you can set condition  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=2)  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=3)  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=4)  
           BEGIN  
            PRINT @value   
           END  
   set @pos = CHARINDEX(',', @valueList, @pos+@len) +1  
 END  


Thursday, October 22, 2015

SQL Table Row Data show in column data




 SELECT *  
 FROM (SELECT CAST(mlblmsg AS varchar(max)) AS mlblmsg,clblcode FROM warninglabels) t  
 PIVOT (MAX(mlblmsg)  
 FOR clblcode IN ([0001],[0002],[003],[0004],[0005],[0006]))p  



How to find if a Column is used anywhere in the database

To get the table where this column use you can use this query.

 SELECT *  
 FROM sys.tables  
 WHERE tables.object_id IN (SELECT  
      OBJECT_ID  
 FROM sys.columns  
 WHERE columns.name LIKE '%CDRUGNAME%') -- use your column name  


Tuesday, September 15, 2015

WPF mvvm passing popup viewmodel value in to main viewmodel




I have a scenario that I have a WPF usercontrol UI, from this UI I will call a pop up usercontrol UI.
When I will select a value from pop up usercontrol UI Grid, then popup ui will be close and the selected popup grid value will get in main UI without visual state change of the main UI. 



Main UI ViewModel:

 private void OnInsplanPicker(object sender)  
     {  
       InsurancePlanLookup window = new InsurancePlanLookup();  
       window.BindEvent += window_BindEvent;  
       DockHelper.AddPanel(window,"Insuranceplan lookup");  
     }  
     void window_BindEvent(long insplanId)  
     {  
       Nhinsplanid_FK = insplanId;  
     }  




Popup code behind

 public partial class InsurancePlanLookup  
   {  
     public delegate void BindDelegate(long insplanId);  
     public event BindDelegate BindEvent;  
     VMInsurancePlanLookup vm ;  
     public InsurancePlanLookup()  
     {  
       InitializeComponent();  
       vm = new VMInsurancePlanLookup();  
       vm.BindEvent += vm_BindEvent;  
       vm.CloseEvent += vm_CloseEvent;  
       DataContext = vm;  
     }  
     void vm_BindEvent(long insplanId)  
     {  
       BindEvent(insplanId);  
       DockHelper.ClosePanel(Parent);  
     }  
     void vm_CloseEvent()  
     {  
       DockHelper.ClosePanel(Parent);  
     }  
   }  




Popup ViewModel

 public delegate void BindDelegate(long insplanId);  
 public event BindDelegate BindEvent;  
 public ICommand Close { set; get; }  
     public ICommand OkButtonCommand { set; get; }  
     public VMInsurancePlanLookup()  
     {  
       Close = new DelegateCommand(OnClose);  
       OkButtonCommand = new DelegateCommand(OnOkButton);  
       PrepareOriginalList();  
     }  
     private void OnOkButton(object obj)  
     {  
       BindEvent(SelectedInsplan.id);  
     }  
     private void OnClose(object obj)  
     {  
       if (CloseEvent != null)  
       {  
         CloseEvent();  
       }  
     }  







SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...